Skip to content

subscripting variable names?

2 messages · Charles Evans, Brian G. Peterson

#
Hello!

Is there any function that will let me tell R to create plot 1 and  
save it to my hard drive as plot01.png, create plot 2 and save it to  
my hard drive as plot02.png, etc.

I am running several batches of plots that I want to save for use in  
the appendices of my dissertation.  The kludge that I have come up  
with is:

for (i in 1:dim(p)[3]) {
png(width=800,height=640,units="px",bg="white")
plot(residuals(lm(p[,1,i]~n[,1,i],na.action=na.omit)),ylab=i)
}

Then, I use dev.off() to save the top graphic in the stack, rename the  
file on my computer, and repeat.

I have tried using cat() to create indexed filenames, but that did not  
work.  After a couple hours of searching online, I have not been able  
to find a solution.

Any hints would be appreciated.

Yours,

C.Evans

Capital goes where it's welcome and stays where it's well treated.
Walter B. Wriston
#
1> there are several good books on R graphics. read them.

2> this is a question for r-help, please post it there after reading the 
posting guidelines

Regards,

   - Brian
Charles Evans wrote: