Hi Russ,
I'd never really thought about using stat_function for that purpose -
it's basically designed to work with on top of an existing plot.
However, it's pretty easy to make a little function to do what you
want:
fplot <- function(f, .min, .max, ..., .n = 100) {
x <- seq(.min, .max, length = .n)
y <- f(x, ...)
qplot(x, y, data = data.frame(x, y), geom = "line")
}
fplot(dnorm, -3, 3, mean = 0, sd = 1)
(I use . in front of min and max so that you don't inadvertently match
those arguments instead of the arguments of the function that your
plotting)
If you wanted to go even further and automatically come up with good
default limits for the plot, you could use the ideas in here:
http://www.cs.uic.edu/~wilkinson/Publications/plotfunc.pdf
Hadley
--
http://had.co.nz/