Skip to content

Instantly share code, notes, and snippets.

@WalkerHarrison
Last active July 27, 2017 16:34
Show Gist options
  • Save WalkerHarrison/a6e1aa7fb29129d66189609765f66e4b to your computer and use it in GitHub Desktop.
Save WalkerHarrison/a6e1aa7fb29129d66189609765f66e4b to your computer and use it in GitHub Desktop.
library(ggplot2)
set.seed(1)
x <- 1:100
y <- x^2*sin(2*pi*x/100) + 500*rnorm(length(x))
df <- data.frame(x, y)
h <- 12
smoother <- data.frame(ksmooth(x, y, "normal", bandwidth = h, n.points = 100))
ggplot(df, aes(x,y)) + geom_point() + geom_line(data = smoother, aes(x,y))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment