[R] using loops to create multiple images
Donatas G.
dgvirtual at akl.lt
Sun Aug 5 00:59:20 CEST 2007
I have a data.frame with ~100 columns and I need a barplot for each column
produced and saved in some directory.
I am not sure it is possible - so please help me.
this is my loop that does not work...
vars <- list (substitute (G01_01), substitute (G01_02), substitute (G01_03),
substitute (G01_04))
results <- data.frame ('Variable Name'=rep (NA, length (vars)),
check.names=FALSE)
for (i in 1:length (vars)) {
barplot(table(i),xlab=i,ylab="Nuomonės")
dev.copy(png, filename="/my/dir/barplot.i.png", height=600, width=600)
dev.off()
}
questions:
Is it possible to use the i somewhere _within_ a file name? (like it is
possible in other programming or scripting languages?)
Since I hate to type in all the variables (they go from G01_01 to G01_10 and
then from G02_01 to G02_10 and so on), is it possible to shorten this list by
putting there another loop, applying some programming thing or so?
--
Donatas Glodenis
http://dg.lapas.info
More information about the R-help
mailing list