Closed yihui closed 13 years ago
Thanks, I was always wondering about that, just put it in and it seems to work!
Issue 20 reminds us that this null device does not work for certain cases...
An old issue came to my mind again: is it possible to evaluate the code chunk only once when fig=T
? I guess the original design of Sweave wanted to produce plots of more than one formats (typically pdf and eps), so Sweave repeats the evaluation of a code chunk in every graphics device.
Nowadays, I think we rarely worry about whether people run latex (eps) or pdflatex (pdf); I have not used eps figures for several years. A single graphics device should be enough for every code chunk, so can we open that graphics device before we evaluate the code? In this case, there will not be any Rplots.pdf
any more, and it will also save us a lot of time, which is currently wasted in producing those redundant files. This is the real solution to issue 20 and this issue. However, I guess it might require some sort of rewriting Sweave. You may discard this idea. I can stand the redundancy :)
I have yet to dig into the Sweave code to find out exactly how or why this is how it is. But is is good to keep in mind and check into later.
If you have not solved that problem, I guess here is the answer: http://yihui.name/en/2010/12/a-special-graphics-device-in-r-the-null-device/