r - Convert spline interpolation to linear interpolation? -
this function below doing job spline interpolation wonder how can modify linear interpolation instead!
## function interpolate using spline imagespline = function(x, y, xout, method = "natural", ...){ x.max = max(xout) x.spline = spline(x = x, y = y, xout = xout, method = method, ...) x.spline }
see ?approx
approx()
, approxfun()
. these linear interpolation counterparts spline()
, splinefun()
.
depending on detail of linear interpolation want perform (see ?approx
details , things tweak), simple as:
imageapprox <- function(x, y, xout, ...) { x.linear <- approx(x = x, y = y, xout = xout, ...) x.linear }
Comments
Post a Comment