# 21 points close to the quadratic x^2 - 5*x + 6
x <- seq(-2,5,length=21)
set.seed(7766)
eps <- rnorm(21,mean=0,sd=0.5)
y <- x^2-5*x+6+eps
# Data frame
pts <- data.frame(x=x,y=y)
# Try function without plot
ddd <- which_poly(pts,plt=FALSE)
print(ddd)
# Try function with plot and extending
# highest polynomials' degree to 10
ddd <- which_poly(pts,mmax=10)
Run the code above in your browser using DataLab