data visualization - Layer plots in R -


i need layer scatterplot , alleffects plot. here example data:

library("effects") x<-c(1,2,6,7,4,3,5) y<-c(5,6,3,6,9,4,4) a<-as.factor(c(1,1,1,2,2,2,2)) xyplot(y ~ x|a) lm.y<-lm(y~x*a) plot(alleffects(lm.y)) 

to clear, xyplot layered upon plot(allefects...) plot. appreciate advice.

the package latticeextra provides several functions combine trellis objects: +.trellis, c.trellis , layer family. here need +.trellis:

library("effects") library("latticeextra")  x <- c(1,2,6,7,4,3,5) y <- c(5,6,3,6,9,4,4) <- as.factor(c(1,1,1,2,2,2,2))  pxy <- xyplot(y ~ x|a)  lm.y <- lm(y~x*a) aef <- alleffects(lm.y) 

there problem plot method efflist objects (the result of alleffects): prints trellis object gives no return. trick use plot method eff objects (the components of efflist object) defined return trellis object. effect of example can extracted aef[[1]]:

peff <- plot(aef[[1]]) 

and final step +.trellis:

peff + pxy 

effects layers


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -