2

http://rapporter.github.io/pander/#live-report-generationの例に従って、pander を使用して Windows7 経由で docx レポートを作成しています。

myReport <- Pandoc$new(author="Jerubaal",title="Plot Anything", format="docx")

例を試してみました

myReport$add(plot(1:10))

これは Windows では機能しませんが、Linux では機能します。

以前は、brew ファイルと <%=plot(1:10)=> を使用してプロットを表示していましたが、この方法が私に最も適していると思われるため、Live Report Generation を試しています。

また、最初にプロットをファイルに保存してから画像リンクを作成しようとしましたが、これも 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())

Q: png の作成または保存に時間がかかりすぎると、問題が発生しますか?

4

0 に答える 0