Create multiple graphics in R without multiple calls to pdf / postscript / jpeg / png
R
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 dev.off() once at the end to close all devices!
Check out ?sprintf for more information about %03d and other C-style string formatting.