spl <- smooth.spline(mtcars$wt, mtcars$mpg, df = 4)
head(augment(spl, mtcars))
head(augment(spl)) # calls original columns x and y
library(ggplot2)
ggplot(augment(spl, mtcars), aes(wt, mpg)) +
geom_point() + geom_line(aes(y = .fitted))
Run the code above in your browser using DataLab