equation for lm graphics
I'm doing graphics with lm relation, and I want to archive and to plot for each one of them an equation y=ax+b
with R². How can I do it?
lmfit <- geom_smooth(method="lm", se =开发者_如何转开发 T)
p <- qplot(x, y, data=Tab) + facet_grid(id ~., scales = "free") + lmfit
Within ggplot
, there is no direct way to do this. You need to compute the regressions separately for each id
and then extract the equation and R^2 from each of those. Put those extracted versions in a dataframe (along with id
) and use geom_text
to display them.
精彩评论