[R] output a sequence of plots

Don MacQueen macq at llnl.gov
Wed Oct 5 22:42:30 CEST 2005


Something similar to this
(but I haven't tested)

mydf <- data.frame(xx=rnorm(100), yy=rnorm(100), zz=rnorm(100))

for (nm in names(mydf)) {

   fnm <- file.path('c:',paste(nm,'.emf',sep=''))
   cat('Creating histogram in file',fnm,'\n')
   win.metafile( filename=fnm)
   hist(mydf[[nm]])                                          # or 
hist(mydf[,nm])
   dev.off()

}

-Don

At 11:54 AM -0400 10/5/05, Paul E. Green wrote:
>I can output two histograms of variables
>AXFILTERED and AZPTOP as follows:
>
>win.metafile(filename="C:/AXFILTERED.emf",pointsize=12)
>hist(AXFILTERED,breaks=40)
>dev.off()
>
>win.metafile(filename="C:/AZPTOP.emf",pointsize=12)
>hist(AZPTOP,breaks=40)
>dev.off()
>
>But, I actually have a dataframe of 120 variables that I
>would like histograms of. Any solutions that would
>save me from repeating this code 120 times? Can I
>pass arguments inside quotes? Can I write a function
>to do this?
>
>Paul Green
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


-- 
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA




More information about the R-help mailing list