Skip to content
Prev 236317 / 398500 Next

Obtaining lattice equivalent smoothed (loess) plot in ggplot

Hello,
My apologies, it was the hotmail writer which ate my post (hopefully this will get there, intact).

dd<-rbind(data.frame(rbind(c("V1","A",0.3),c("V2","A",0.5),c("V3","A",0.2))),?? ? ?data.frame(rbind(c("V1","B",0.3),c("V2","B",0.4),c("V3","B",0.8))),?? ? data.frame(rbind(c("V1","C",0.9),c("V2","C",0.2),c("V3","C",0.4))))
require(lattice)?
# Lattice Code -- this is the behaviour that I need to replicate in ggplot# No it is not a home work assignment, I did home work about 25 years ago# This is for my work, I would like the aesthetics of ggplot :)#xyplot(X3 ~ X1, data=dd, type="l", group=X2,??? ? panel = function(x,y,...)?	{ 	panel.xyplot(x,y,...)??? ?		panel.loess(x,y,lty=2,lwd=1,...)	})?
# This is the ggplot(2) code, it probably does what it is supposed to i.e. group# but not the behaviour shown by the lattice code#
p <- ggplot(dd, aes(x=X1,y=X3,group=X2))p <-p + geom_smooth(method = "loess",se=FALSE, lty=2,lwd=1)p + geom_line(aes(col=X2))?

I have the plot above in Lattice, but would like to get a ggplot2 plot for a presentation (i.e. it just looks nice). (I am not sure whether somebody would set something like this for a home work assignment).
Cham.
________________________________