4

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?

radek
  • 7,240
  • 8
  • 58
  • 83
  • 2
    If the vector graphics get so big (find out which graphs exactly) it might be preferable to turn them into PNGs with a good resolution instead. – Roland May 27 '13 at 08:54
  • @Roland Thanks for the tip. Is there a way to do it from within `knitr`? – radek May 27 '13 at 08:59

1 Answers1

5

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
@
agstudy
  • 119,832
  • 17
  • 199
  • 261
  • 2
    Thanks for that - solved the problem. I changed global chunk options in `opts_chunk$set` and the pdf has been reduced to 8MB. The main culprit seemed to be the large maps. There is a significant reduction n image quality of course, but as a 'working copy' it works perfectly. – radek May 27 '13 at 10:50