且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法在 Rmarkdown 报告中生成交互式绘图

更新时间:2022-12-03 19:43:50

试试:

Rscript -e "library(knitr); library(rmarkdown); rmarkdown::render('untitled.Rmd', output_file='report.html')"

推理:knit似乎默认为markdown输出,而markdown不能包含HTML.因此,在转换时,您最终会丢失文件(如果从代码块开口中删除 echo=FALSE,您会看到这些错误.

Reasoning: knit seems to default to markdown output, and markdown cannot contain HTML. Thus, when converting, you end up with missing files (you can see these errors if you remove echo=FALSE from the code block openings.

rmarkdown::render([...]) 干净地呈现为 HTML,避免了上述问题.如果您想指定输出格式,可以使用 output_format 参数.

rmarkdown::render([...]) renders cleanly to HTML, avoiding the issues mentioned above. If you wish to specify the output format, you can do so using the output_format argument.