I tried to use a plotly figure in a pdf through an rmd file. I used the simple method described in: https://plot.ly/r/knitr/ I have the following sessionInfo:
> packageVersion('plotly')
[1] ‘4.9.0’
> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
other attached packages:
[1] plotly_4.9.0 ggplot2_3.2.0
It works fine. When I try the same exact thing on a machine with R 3.4.4 with sessionInfo:
> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 16299)
other attached packages:
[1] plotly_4.9.1 ggplot2_3.2.0
I get the error:
Error: 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: yes
Note however that the HTML output will not be visible in non-HTML formats.
Is this an R issue? what am I missing ?
I was getting the same error running R 4.1.2 when I found that one solution was installing the webshot package and running the webshot::install_phantomjs()
command to install phantomjs. Unfortunately, webshot was not available for R 4.1.2, so I install R 4.0.3, installed webshot and phantomjs and this finally allowed me to compile the Rmd to pdf.