在Sweave中制作扁平化的pdf [英] Making flattened pdfs in Sweave

查看:269
本文介绍了在Sweave中制作扁平化的pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在使用Sweave创建pdf文件,其中包括一些带有大量标记的图形.我可以很好地获得pdf,但是它似乎已经创建了很多层,因此很难在Acrobat或Reader中打开文件.当我这样做时,我实际上可以观察到点在文档上的负载.

So I am creating pdfs using Sweave that include some graphs that have a ton of points on them. I can get the pdf well enough, but it seems to have created it with a ton of layers, so it's hard to open the file in Acrobat or Reader. When I do, I literally can watch the points load on the document.

是否有一种方法可以使Sweave中的pdf扁平化,以免显得不那么笨重?

Is there a way to flatten the pdf in Sweave so that it's not so bulky?

(请注意,我正在使用RStudio.我知道我可能还应该使用其他功能,但是我还没有发现任何可以使此工作顺利进行的功能.)

(Note that I am using RStudio. I know I should probably be using something else, but I haven't found anything that has worked this smoothly yet.)

推荐答案

正如Gavin所说,尽管这样做还有其他优点,但无需切换到knitr.但是,您甚至不需要编写自己的保存和包括代码;您甚至不需要编写代码. Sweave可以为您做到这一点.如果初始文档为:

As Gavin said, there is no need to switch to knitr for this, though there are other advantages to do so. However, you don't even need to write your own saving and including code; Sweave can do that for you. If the initial document is:

\documentclass{article}
\usepackage[american]{babel}
\begin{document}

<<>>=
n <- 100000
DF <- data.frame(x=rnorm(n), y=rnorm(n))
@

<<gen_fig, fig=TRUE>>=
plot(DF)
@

\end{document}

然后只需将参数更改为图形块,就可以获取PNG而不是PDF:

Then just by changing the arguments to the figure chunk, you can get a PNG instead of a PDF:

<<gen_fig, fig=TRUE, png=TRUE, pdf=FALSE>>=
plot(DF)
@

在这个简单的示例中,它将最终的PDF从685K缩小到70K.

In this simple example, it shrinks my final PDF from 685K to 70K.

这篇关于在Sweave中制作扁平化的pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆