I'm new here, can I ask a question?

What should I do when rstudio says this during knitting to word file?

Error: Functions that produce HTML output found in document targeting docx output.
Please change the output type of this document to HTML. Alternatively, you can allow
HTML output in non-HTML formats by adding this option to the YAML front-matter of
your rmarkdown file:

always_allow_html: true

Note however that the HTML output will not be visible in non-HTML formats

Hi,

That comment means you're trying to knit an RMarkdown or Quarto file to docx (Word), but it contains interactive HTML elements. Does your file have something like a plotly graph, leaflet map or DT/reactable table?

If you add what it suggests to your YAML header, i.e.,

---
title: My Cool Report
always_allow_html: true
---

It should render okay. Note that the interactive elements may be absent entirely, though.

Commonly, I use an if/else statement with knitr::is_html_output() so that if my output is HTML it'll show, e.g., a leaflet map, but if it is a pdf/word it'll put in a static ggmap.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.