[R] densityplot png in a for loop
Gabor Grothendieck
ggrothendieck at gmail.com
Fri Feb 9 12:54:26 CET 2007
Check out:
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f
On 2/9/07, Albert Vilella <avilella at gmail.com> wrote:
> 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.
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list