Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. library(ggplot2)
  2. set.seed(1)
  3.  
  4. x <- 1:100
  5. y <- x^2*sin(2*pi*x/100) + 500*rnorm(length(x))
  6.  
  7. df <- data.frame(x, y)
  8. h <- 12
  9. smoother <- data.frame(ksmooth(x, y, "normal", bandwidth = h, n.points = 100))
  10.  
  11. ggplot(df, aes(x,y)) + geom_point() + geom_line(data = smoother, aes(x,y))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement