[R] Defining different objects within a loop

Deepayan Sarkar deepayan.sarkar at gmail.com
Mon Aug 3 20:09:43 CEST 2009


On Thu, Jul 30, 2009 at 3:09 PM, jimdare<jamesdare26 at gmail.com> wrote:
>
> Dear R Users,
>
> I have a dataset that I have split by group.  For each group I plot a figure
> using:
>
> for (i in splitdf){
> plot<-xyplot(................)
> print(plot)
> savePlot(filename=paste(i$Group[1]),type="pdf")
> }
>
> This gives me X pdf files where X is the number of groups.
> Does anyone know a simple way to get the name of the plot [plot<-xyplot()]
> to differ for each rin of the loop so I can merge them into a single pdf
> files using.
>
> pdf(filename="mergedplots")
> plot1
> ....
> plotX
> dev.off()

Whats wrong with

pdf(file="foo.pdf")

for (i in splitdf) {
   plot<-xyplot(................)
   print(plot)
}

dev.off()

?

-Deepayan




More information about the R-help mailing list