[R] densityplot png in a for loop

Petr Pikal petr.pikal at precheza.cz
Fri Feb 9 12:46:04 CET 2007


Hi 

Most probably see the FAQ 7.22 Why do lattice/trellis graphics not 
work?

HTH
Petr




On 9 Feb 2007 at 11:28, Albert Vilella wrote:

Date sent:      	Fri, 9 Feb 2007 11:28:07 +0000
From:           	"Albert Vilella" <avilella at gmail.com>
To:             	r-help at stat.math.ethz.ch
Subject:        	[R] densityplot png in a for loop

> 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.

Petr Pikal
petr.pikal at precheza.cz



More information about the R-help mailing list