[R] xyplot Graphic Help

Gabor Grothendieck ggrothendieck at gmail.com
Mon Oct 2 04:16:03 CEST 2006


That's note the only problem.  The point ("B", 14) is plotted at ("C", 14).

Your problem is that:

> factor(letters)[2:3, drop = TRUE]
[1] b c
Levels: b c

so now b has level 1 and c has level 2 so if you try to plot b from the
original factors where it was 2 it will show up above c and c will not
show up at all since it corresponds to 3.

By the way, please reduce your examples to the minimum code necessary
to illustrate the point and still be reproducible as requested on the last
line of every message on r-help.

On 10/1/06, Shawn Way <shawnway at yahoo.com> wrote:
> I have the following graphic where I drop unused factors in the x axis, however I cannot get the first point on the second panel. It seems shifted.  Any ideas?
>
> The example is below:
>
> data <- data.frame(
>                   Room=as.factor(c(132,132,132,132,132,132,132,132,132,196,196)),
>                   Sample=as.factor(c("A","B","C","J","K","L","M","N","O","B","C")),
>                   Particulates=c(90,300,400,300,400,300,500,200,300,14,52),
>                   Class=as.factor(c(100000,100000,100000,100000,100000,100000,100000,100000,100000,10000,10000))
>                   )
> a <- data$Class
> print(
>      xyplot(Particulates~Sample|Room,
>       data=data,
> #       groups=Room,
>       type="p",
>       xlab=list(label="Sample Site",cex=3),
>       ylab=list(label=expression(paste("Particles" >= "0.5 ",mu,"m/ft"^"2")),cex=3),
>       ylim=c(-100,1200),
> #       index.cond=list(c(2,1)),
>       scales=list(x=list(relation="free", cex=2),y=list(cex=2)),
>       prepanel=function(x,y,... ) {
> #         yy <- y[,drop=TRUE]
>         xx <- x[,drop=TRUE]
>         list(xlim=levels(xx),
> #              ylim=levels(yy),
>              xat=sort(unique(as.numeric(xx)))
> #              yat=sort(unique(as.numeric(yy)))
>              )
>       },
>       panel=function(x,y,subscripts,m=a, ...) {
> #          yy <- y[,drop=TRUE]
>         panel.xyplot(x,y,...)
>         panel.abline(h=m[subscripts],col="red")
>         panel.abline(h=mean(y,na.rm=TRUE),col="green")
> #         panel.segments(x,y,...)
>       }
>              )
> )
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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