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

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.

About Vinh Nguyen

Statistician

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>