Create multiple graphics in R without multiple calls to pdf / postscript / jpeg / png


Vinh Nguyen


May 15, 2009

To save multiple graphics, e.g, Rplot001.pdf, Rplot002.pdf, …, Rplot050.pdf, we don't have to call pdf() 50 times (or another graphics device function) in R. Instead, use Rplot%03d.pdf for the filename argument in pdf() and each plot() call will be saved to a new pdf file. Run once at the end to close all devices!

Check out ?sprintf for more information about %03d and other C-style string formatting.