[R] ggplot2 - regression statistics how to display on plot

2011-11-10 Thread Durant, James T. (ATSDR/DTEM/PRMSB)
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

Re: [R] ggplot2 - regression statistics how to display on plot

2011-11-10 Thread Bryan Hanson
Jim, you can use the function appended below, which is part of package HandyStuff. If you want an example, see ?lmEqn after installing HandyStuff, available at github.com/bryanhanson/HandyStuff. Bryan lmEqn - function(df = NULL, y = NULL, x = NULL, method = lm, leg.loc = c(0, 0),

Re: [R] ggplot2 - regression statistics how to display on plot

2011-11-10 Thread Dennis Murphy
Hi: Here's an example of how one might do this in a specific example using geom_text(). # Some fake data: df - data.frame(x = 1:10, y = 0.5 + (1:10) + rnorm(10)) # Fit a linear model to the data and save the model object: mod - lm(y ~ x, data = df) # Create a list of character strings - the