[R] Regression using ggplot2

Chris89 chrisege at stud.ntnu.no
Mon Sep 9 13:52:40 CEST 2013


Hi!
I am currently working with a project where I want to plot the regression
line in a plot using ggplot.
The problem occurs when I want to add the second variable, i.e. the z in the
source code:

p = ggplot(data = dat, aes_string(x = "sd", y = "mean", z = "corr"))  
p = p + stat_smooth(method = lm, formula = y~x+z, se = FALSE, size = 0.75,
linetype = "solid")
p = p + geom_point()
plot(p)

I´m not sure if it is even possible to do multiple regression using
stat_smooth, in which case do you have any alternative method?

Best regards
Chris



--
View this message in context: http://r.789695.n4.nabble.com/Regression-using-ggplot2-tp4675676.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list