如何在 ReporteRs 包中添加 Plot 到 bsdoc 文档?

How addPlot to bsdoc document in ReporteRs package?

我正在尝试向 ReporteRs 包中的 bsdoc 添加绘图。当我 运行 tutorial site 上的示例时,它只返回 table。情节无处可寻。是错误还是我做错了什么?我正在使用虚拟机并尝试了不同的浏览器(IE、chrome、Firefox)但没有成功。

library( ReporteRs )

# Creation of mydoc
mydoc = bsdoc( title = 'my document' )

# add into mydoc first 10 lines of iris
mydoc = addFlexTable( mydoc, vanilla.table(iris[1:10,] ) )

mydoc = addParagraph( mydoc, value = "Hello World!" )

# add a plot into mydoc 
mydoc = addPlot( mydoc, function() barplot( 1:8, col = 1:8 ) )

# write the doc 
writeDoc( mydoc, file = "examples/htmloutput/bsdoc_simple_example.html" )

编辑 教程说 "Note that other files will be copied in the directory containing the html file (i.e. the bootstrap css, js directories)." 就我而言,这不会发生。所以也许这就是我的问题的原因。我仍然不知道如何解决这个问题。

EDIT2 html 输出包含 link 表示 'Skip to main content'。是不是也有点奇怪?

这个问题的答案是文件夹不应该已经创建。它应该由模块创建。

I ran the above method using both by creating the folder and not creating it

js,css等文件只在folder is not available

时创建

The function needs to create a folder not necessarily examples/htmloutput/

i.e.

writeDoc( mydoc, file = "outputs/bsdoc_simple_example.html" )

如果文件夹不可用,将创建一个文件夹,并在文件夹中创建所有需要的文件 但是,如果可用,则它只会创建 HTML 文件