[R] add different regression lines for groups on ggplot
Ye Lin
yelin at lbl.gov
Fri Jul 26 21:21:23 CEST 2013
Hey All,
I need to apply different regression lines to different group on my ggplot,
and here is the code I use:
qplot(x=Var1,y=Var2,data=df,color=SiteID,group=SiteID)+geom_point()+geom_smooth(method='lm',formula=log(y)~I(1/x),se=FALSE,size=2)
However the regression for different groups is as below:
AL1/AL2: log(y)~I(1/x)
AL3: log(y)~log(x)
How can I apply each regression equation on the same ggplot?
Also I have an issue that if I use the code above, the regression lines are
not overlapped on top of my data points.
Thanks for your help!
More information about the R-help
mailing list