Hello -

So I am trying to use ggplot2 to show a linear regression between two 
variables, but I want to also show the fit of the line on the graph as well.

 I am using ggplot2 for other graphics in what I am working on, so even though 
this would be a fairly easy thing to do in Excel, I would prefer to do it in R 
to keep my look and feel, and I think ggplot2 is just cooler.

Here is a sample script of what I am trying to accomplish:

df<-NULL
df$x<-rnorm(100)
df$y<-rnorm(100)
df<-data.frame(df)

ggplot(df, aes(x=x,y=y))+geom_point()+geom_smooth(method=lm)


# would like to be able to showr squared and slope/intercept of lm

VR

Jim


James T. Durant, MSPH CIH
Emergency Response Coordinator
US Agency for Toxic Substances and Disease Registry
Atlanta, GA 30341
770-378-1695





        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to