boxuancui / DataExplorer

Automate Data Exploration and Treatment
http://boxuancui.github.io/DataExplorer/
Other
512 stars 88 forks source link

Add YAML option to allow html elements when choosing PDF report #154

Closed etiennebacher closed 3 years ago

etiennebacher commented 3 years ago

Producing a PDF output with create_report() causes an error because there are several networkD3 functions that are called in the rmd_template, but they can only be produced in an HTML output. For example:

create_report(iris, output_file = "report.pdf", output_format = "pdf_document") 

... Compilation message...

Erreur : Functions that produce HTML output found in document targeting latex 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.

Therefore, I added the line specified in the error message (always_allow_html: true) in the YAML. An alternative solution would be to wrap the lines concerned in if (knitr::is_html_output()).