Search code examples
rplotknitrcran

How do I make plots appear in a knitr vignette using dev.new()?


My package produces a number of graphs, often more than one at once.

Using x11 or windows devices there is no problem, knitr builds the vignette with images included.

However a requirement of submission to the CRAN repository is the use of dev.new for platform independent plotting. If I replace x11 or windows with dev.new then no images appear in my vignette.

Is there a solution to this? At first I thought this was related to plotting in RStudio but use of the new argument dev.new(noRStudioGD = FALSE) did not help. Additionally building the package from the command line did not solve the problem.

Cheers,

Tom

(Windows 7 x64) (R 3.1.1) (RStudio 0.98.507)


Solution

  • The short answer is, you do not use dev.new() at all (or dev.off() or dev.whatever...). If you want a longer answer, please include a minimal reproducible example demonstrating what your problem really is.