# make random data set
set.seed(1)
x = runif(100)
y = sin(2*pi*x)+rnorm(100, sd=0.5)
plot(x,y,pch=16)
# smoothed spline
f = smoothfun(x, y)
curve(f, add=TRUE, col='red')
# smoothed spline with custom degree of freedom
g = smoothfun(x, y, df=5)
curve(g, add=TRUE, col='blue')
Run the code above in your browser using DataLab