[R] Odp: Lattice in a loop does not produce output
Petr PIKAL
petr.pikal at precheza.cz
Tue Aug 18 14:38:31 CEST 2009
Hi
r-help-bounces at r-project.org napsal dne 18.08.2009 14:13:12:
> I cannot understand why xyplot does not work within a simple for loop.
>
> This works up to the for loop; inside the for loop the png files are
> opened and closed, but nothing is plotted. No error messages are written
> to the console either. This is the case on both Windows and Linux.
>
> By the way, running the script below on Linux using source() does not
> even produce the first xyplot. This is less of an issue for me though.
>
> #! usr/bin/env R
> # Test lattice loop
>
> rm(list=ls())
>
> x<-1:16
> y<-2*x-1
> z<-rep(c('A','B','C','D'),4)
>
> xyz<-data.frame(x=x,y=y,z=z)
>
> require(lattice)
>
> png('Test.png')
> xyplot(y~x|z)
> dev.off()
>
> for (i in 1:5) {
> f<-paste('Test',i,'.png',sep='')
> png(f)
> xyplot(y~x|z)
print(xyplot(y~x|z))
Shall be mentioned in help page somewhere, just look.
Regards
Petr
> dev.off()
> }
>
> ______________________________________________
> R-help at r-project.org 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