I would like to graph a function with ggplot2, but I'm not sure how to do that (still beginning in R). I did the following code, but this doesn't work:
f <- function(x, a, b, c) a + b*x - c*x^2 formals(f)$a <- 0.39384 formals(f)$b <- 0.03895 formals(f)$c <- 0.00069 optimize(f, c(0, 51), maximum = T) ggplot(data.frame(x=c(0, 51), aes(x=x, a=a, b=b, c=c)) + stat_function(fun=f)
Anyone could show me how to do that?
Thanks a lot!