简体   繁体   中英

How to reduce size of knitr generated pdf file?

I'm working with Rnw file that I knit into a pdf report.

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. I believe it is mostly caused by the vector (pdf) graphics included.

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:

<<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
@

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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