I\'m trying to draw a smooth curve in R. I have the following simple toy data:
R
> x [1] 1 2 3 4 5 6 7 8 9 10 > y [1] 2 4 6 8
In ggplot2 you can do smooths in a number of ways, for example:
library(ggplot2) ggplot(mtcars, aes(wt, mpg)) + geom_point() + geom_smooth(method = "gam", formula = y ~ poly(x, 2)) ggplot(mtcars, aes(wt, mpg)) + geom_point() + geom_smooth(method = "loess", span = 0.3, se = FALSE)