2010-07-22 132 views
0

我需要创建一个pdf文件,并在A4纸中排列由ggplot2创建的多个图表,并重复20-30次。尝试通过grImport导入ps文件时发生错误R

我的ggplot2图表导出到PS文件,并尝试PostScriptTrace它作为grImport指示,但它只是不停地给我的Unrecoverable error, exit code 1错误。

我忽略错误并尝试导入和XML文件生成为R对象,再给我一次错误:

attributes construct error
Couldn't find end of Start Tag text line 21
Premature end of data in tag picture line 3
Error: 1: attributes construct error
2: Couldn't find end of Start Tag text line 21
3: Premature end of data in tag picture line 3

有什么不对吗?

谢谢!

+1

你为什么要导出为.ps文件,然后用PostScriptTrace导入它?难道你不能直接以'pdf()'作为.pdf保存吗? – nullglob 2010-07-22 06:49:51

+0

同意,使用'pdf()'可能会更容易,或者更好的办法是使用'Sweave'来创建你的PDF输出。 如果你不熟悉'Sweave',我推荐这个教程:http: //jeromyanglim.blogspot.com/2010/02/getting-started-with-sweave-r-latex.html – DrewConway 2010-07-22 18:01:01

回答

0

如果您没有时间处理Sweave,您也可以在生成图表后编写一个简单的TeX文档,您可以稍后编译为pdf。

例如为:

ggsave(p, file=paste('filename', id, '.pdf')) 
    cat(paste('\\includegraphics{', 
     paste('filename', id, '.pdf'), '}', sep=''), 
     file='report.pdf') 

后来,你可以很容易地编译它与例如pdflatex为PDF。

相关问题