[R] trellis graphics in loops
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Sun Jan 30 17:38:41 CET 2005
Jean Eid <jeaneid at chass.utoronto.ca> writes:
> I have this awkward problem with trellis (lattice). I am trying to
> generate some plots through loops but the .eps file is empty. When I
> generate them in a list and print them outside the loop all is fine. this
> is an example below:( nothing shows up in foo.eps, but all show up in
> foo1.eps)
> R vesion 2.0.1, lattice version 0.10-16, on a debian 2.6.8-1 kernel.
>
>
> X <- data.frame(x=rnorm(10000), y=rnorm(10000), z=sample(c("foo1","foo2"),
> 10000,replace=T), year=sample(c(89:94), 10000,replace=T))
> trellis.device("postscript", file="foo.eps")
> for(i in unique(X$year)){
> temp <- X[X$year%in%i, ]
> xyplot(temp$x~temp$y|temp$z)
> }
> dev.off()
You need to print(xyplot(....)).
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list