Error message: Error in approx(sp$y, sp$x, xout = cutoff) : need at least two non-NA values to interpolate In addition: Warning message: In regularize.values(x, y, ties, missing(ties), na.rm = na.rm) : collapsing to unique 'x' values

See the FAQ: How to do a minimal reproducible example reprex for beginners. It's difficult to analyze an error like this in the abstract. The best I can suggest is this post.