Re: [R] Adding a regression line to an xyplot

2010-02-14 Thread David Winsemius
On Feb 14, 2010, at 6:33 PM, Andrew McFadden wrote: Hi R users I am trying to add a regression line to a graph for "c" for factor 2 only. Any suggestions? library(lattice) a=(1:10) b=c(1:5,16:20) c=as.factor(c(rep(1,5),rep(2,5))) d=data.frame(a,b,c) xyplot(a~b, pch=c(6,8),data = tavg, gr

[R] Adding a regression line to an xyplot

2010-02-14 Thread Andrew McFadden
Hi R users > I am trying to add a regression line to a graph for "c" for factor 2 > only. Any suggestions? > library(lattice) a=(1:10) b=c(1:5,16:20) c=as.factor(c(rep(1,5),rep(2,5))) d=data.frame(a,b,c) xyplot(a~b, pch=c(6,8),data = tavg, groups=d$c, reg.line=lm, smooth=FALSE, type=c("p","g")