Windows 如何使用pander';s实时报告生成

Windows 如何使用pander';s实时报告生成,windows,r,ggplot2,pandoc,pander,Windows,R,Ggplot2,Pandoc,Pander,我正在使用pander通过Windows7创建docx报告,如下所示 这在Windows上不起作用,但在Linux上起作用 以前,我使用brew文件和脚本显示绘图,但我正在尝试生成实时报告,因为这种方法似乎最适合我 我还尝试先将绘图保存到文件,然后创建一个图像链接,该链接在Linux中同样有效,但在Windows中不起作用: myReport$add("![](plots/myplot.png)") 我想包括ggplot2绘图-代码在R中独立工作,但不会出现在docx中(尽管我得到了一个空行)

我正在使用pander通过Windows7创建docx报告,如下所示

这在Windows上不起作用,但在Linux上起作用

以前,我使用brew文件和脚本显示绘图,但我正在尝试生成实时报告,因为这种方法似乎最适合我

我还尝试先将绘图保存到文件,然后创建一个图像链接,该链接在Linux中同样有效,但在Windows中不起作用:

myReport$add("![](plots/myplot.png)")
我想包括ggplot2绘图-代码在R中独立工作,但不会出现在docx中(尽管我得到了一个空行)

R版本3.0.2(2013-09-25)-“飞盘航行” pandoc.exe 1.12.2.1

我错过了什么?谢谢

编辑:我回到家,这在Ubuntu上运行:

library(pander)
library(ggplot2)
setwd("/home/jerubaal/R/Projects/reports")
attach(movies)
m=movies[sample(nrow(movies), 1000),]
myReport=Pandoc$new(author="Jerubaal",title="Testing plots in reports",format="docx")
myReport$add.paragraph("There should be a plot after this")
p=ggplot(data=m, aes(x=rating,fill=mpaa)) + geom_density(alpha=0.25)
ggsave(filename=paste(getwd(),"plots/movies.png",sep="/"),plot=p,width=6,height=3)
myReport$add(paste("![](",paste(getwd(),"plots/movies.png",sep="/"),")",sep=""))
myReport$add.paragraph("There should be a plot before this")
myReport$export(tempfile())

问:如果png的创建或保存时间太长,会不会导致问题?

Hm,这似乎是一个奇怪的错误-请您添加更多细节(可能在)。我尝试在Windows XP下用R3.0.2和最新版本的
pander
(通过
库(devtools)从GH安装);安装_github('pander','reporter')
),但没有成功。它在这里运行良好(使用
base
ggplot
)。我想我可以重现该错误,这似乎是Windows上的路径问题。请尝试将
ggplot
表达式直接放入
myReport$add
并调用
myReport$export
,而不使用
tempfile()
argument.太棒了!很有效!我昨天在github上写了一个问题,但在提交之前关闭了我的计算机…非常感谢@daroczig
myReport$add("![](plots/myplot.png)")
library(pander)
library(ggplot2)
setwd("/home/jerubaal/R/Projects/reports")
attach(movies)
m=movies[sample(nrow(movies), 1000),]
myReport=Pandoc$new(author="Jerubaal",title="Testing plots in reports",format="docx")
myReport$add.paragraph("There should be a plot after this")
p=ggplot(data=m, aes(x=rating,fill=mpaa)) + geom_density(alpha=0.25)
ggsave(filename=paste(getwd(),"plots/movies.png",sep="/"),plot=p,width=6,height=3)
myReport$add(paste("![](",paste(getwd(),"plots/movies.png",sep="/"),")",sep=""))
myReport$add.paragraph("There should be a plot before this")
myReport$export(tempfile())