[R] densityplot png in a for loop
Albert Vilella
avilella at gmail.com
Fri Feb 9 12:28:07 CET 2007
Hi all,
I am trying to plot a list of densityplots as png files, but when I do
it in a for loop, I get empty png files as a result.
If I manually run the instructions inside the loop, it works... any hints?
library(lattice)
names_list = c("alfa","beta","gamma")
for (i in 1:length(names_list)) {
pngfile = paste("example_",names_list[i],".png", sep="")
png(file=pngfile, width=1280,height=1024)
input = rnorm(1000,i)
densityplot(~input,
plot.points=FALSE,
auto.key=TRUE
)
dev.off()
}
Thanks,
Albert.
More information about the R-help
mailing list