An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-help/attachments/20051005/d0a82be8/attachment.pl
output a sequence of plots
3 messages · Paul E. Green, vincent@7d4.com, Don MacQueen
Paul E. Green a ??crit :
... 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?
as a toy example, with some of the usable functions :
(see ?dir)
fct00 = function()
{
rep0 = "data";
fichier = dir(rep0, pattern="*.emf");
nbfichiers = length(fichier);
for (i in 1:nbfichiers)
{
# do the job
}
}
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