Dear Rxperts,
Is there a simpler way to generate multipanel grouped individual profile
plots? All individuals of a group within a panel have the same color.  As
of now I am using lattice::xyplot to get the desired effect. Please feel
free to suggest other ideas.

Also, I am trying to create a generalized function which goes on similar
lines like this..

grpPlot <- function(dat, mpgrp=quote(G), grp=quote(interaction(D,a,drop=T))
{
lines for xyplot as shown below...
}


Below is the sample code... for illustration purposes...

q <-
 
data.frame(G=rep(paste("G",1:3,sep=""),each=50),D=rep(paste("D",1:5,sep=""),each=30),a=rep(1:15,each=10),t=rep(seq(10),15),b=round(runif(150,10,20)))
q$grp <- paste(q$D,q$a,sep=":")
q$grp <-  ordered(q$grp, levels=unique(q$grp))
q$dcol  <- unlist(sapply(q$D,function(x)
        switch(x,"D1"="orange","D2"="blue","D3"="red", "D4"="seagreen",
"D5"="black")))
q2 <- q[order(q$G,q$D,q$a,q$t),]
ref3 <- subset(q2, !duplicated(a))
xyplot(b~t|G,data=q2,groups=grp,type="l",as.table=T,par.settings=my.theme,
    layout=c(3,1), par.strip.text = list(lines = 2),
       scales=list(x=list(rot=90,rela='free',cex=1.3),
                y=list(log=F,at=10**c(0:7),labels=10**c(0:7))),
    panel=panel.superpose,

panel.groups=function(x=x,y=y,subscripts=subscripts,groups=groups,...,group.number)
{
        require(grid)
        panel.xyplot(x=x,y=y,subscripts=subscripts,pch=NA,lwd=1,type="l",
                        col=q2$dcol[subscripts],lty=1,cex=0.7)
         rv0     <-ref3[ref3$G%in%unique(q2$G)[panel.number()],]
         tids    <- paste(as.character(unique(rv0$D)))#
as.character(rv0$NMID)
        tcols   <- unique(rv0$dcol)
        tlty    <- 1
draw.key(list(columns=1,between=1,between.col=0.5,

lines=list(lty=tlty,col=tcols,size=3),text=list(lab=tids,col=tcols,cex=0.8),title="Classes",cex.title=1.1
),
        draw = T,vp = viewport(x = unit(0.8, "npc"), y = unit(0.9, "npc")))
    },

 
strip=strip.custom(strip.names=T,strip.levels=T,par.strip.text=list(cex=1.7,font=2),bg=0,
var.name="School"),
        xlab=deparse(substitute(x)),
        ylab=deparse(substitute(y)),
        main="Overlay of Profiles by Schools and Classes",
)


Thanks so much..
Regards,
Santosh

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to