[R] how to save plots automatically

Yihui Xie xieyihui at gmail.com
Wed Sep 23 07:04:05 CEST 2009


Something like

for(i in 1:20){
  pdf(sprintf("myplot%d.pdf",i))
  # your calculation and plots here
  dev.off()
}

If you have 100 plots in total, then you should have 5 graphs in each
single pdf.

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Tue, Sep 22, 2009 at 10:23 PM, David Winsemius
<dwinsemius at comcast.net> wrote:
>
> On Sep 22, 2009, at 9:50 PM, Weiwei Shi wrote:
>
>> Hi there,
>>
>> I am wondering if there is a function in R to save plots automatically,
>> like
>> save() for R objects? I have e.g. 100 plots and I cannot put them in one
>> pdf
>> file so I split them, eg into 20 files, but I don't want to save one file
>> each time. Can I use a function to do such save.plot as pdf?
>>
>
> ?pdf
>
>
>>
> --
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>




More information about the R-help mailing list