简体   繁体   English

如何减少knitr生成的pdf文件的大小?

[英]How to reduce size of knitr generated pdf file?

I'm working with Rnw file that I knit into a pdf report. 我正在使用Rnw我的文件knitpdf的报告。

All is working smoothly so far, but my report is consists of quite an amount of figures and maps. 到目前为止,一切都很顺利,但我的报告包含了大量的数字和地图。

So the problem that appeared now is that the final version of the report is over 200MB, which makes it quite a pain to share around. 所以现在出现的问题是该报告的最终版本超过200MB,这使得分享很难。 I believe it is mostly caused by the vector (pdf) graphics included. 我相信它主要是由包含的矢量(pdf)图形引起的。

Are there any solutions / strategies to reduce the size of such large report? 是否有任何解决方案/策略来减少此类大型报告的规模?

You can play with the device function to set which graphical device is used to record plots. 您可以使用设备功能来设置用于记录绘图的图形设备。 For latex it is pdf by default, to change it to png (as mentioned by @Roland) you can do this for example: 对于latex,默认情况下是pdf ,要将其更改为png (如@Roland所述),您可以执行此操作,例如:

<<my-label, eval=TRUE, dev='png'>>=
set.seed(1213)  # for reproducibility
x = cumsum(rnorm(100))
mean(x)  # mean of x
plot(x, type = 'l')  # Brownian motion
@

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM