Re: [R] plotting a function with given formula in ggplot2

2011-11-10 Thread Dennis Murphy
Hi: Borrowing from this thread, courtesy of Brian Diggs: http://groups.google.com/group/ggplot2/browse_thread/thread/478f9e61d41b4678/ed323c497db61156?lnk=gst&q=stat_function#ed323c497db61156 ...here's a small reproducible example: ddf <- data.frame(x = 1:10, y = 0.4 + 0.6 * (1:10) + rnorm(10))

Re: [R] plotting a function with given formula in ggplot2

2011-11-10 Thread Curiouslearn
Thanks Rainer. I did not know about dput(). Here is the data. mom_hs <- c(1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1,

[R] plotting a function with given formula in ggplot2

2011-11-10 Thread Curiouslearn
Hi All, I have a scatter plot produced using ggplot2 and I want to add the regression line to this scatter plot. I suppose I can use geom_smooth() to do this, but for the sake of learning ( I am new both to R and ggplot2), I want to try and add it as a function (something that curve() does in the