[R] xyplot() question

Deepayan Sarkar deepayan at stat.wisc.edu
Thu Feb 10 16:56:46 CET 2005


On Thursday 10 February 2005 09:34, Christoph Scherber wrote:
> Dear R Users,
>
> I have an xyplot() where different plotting symbols are used for
> subgroups (originally used within S-Plus, but hopefully it´s also
> applicable to R users).
>  How can I fit separate regression lines for every subgroup? So far,
> I can only plot the overall fitted line.
>
> The code looks like this:
>
> trellis.device()
> sps<-trellis.par.get("superpose.symbol")
> sps$pch<-1:7
> trellis.par.set("superpose.symbol",sps)
>
> spl <- trellis.par.get("superpose.line")
> ps$lty <- 1:7
> trellis.par.set("superpose.line",spl)
> xyplot(a~b|factor+treatment,
> groups=external,data=ownframe,layout=c(2,2),
> panel=function(x,y,subscripts,...){panel.superpose(x,y,subscripts,...
>);panel.lmline(x,y)})

xyplot(a~b|factor+treatment,
       groups=external,data=ownframe,layout=c(2,2),
       panel.groups=function(x,y,...){ 
           panel.xyplot(x,y,...)
           panel.lmline(x,y,...)
       }) 

or

xyplot(a~b|factor+treatment,
       groups=external,data=ownframe,layout=c(2,2),
       type = c('p', 'r'))

Deepayan




More information about the R-help mailing list