Reputation: 159
I'm trying to apply smoothing using smooth.spline
and I keep getting this error. I have excluded NA
from the data frame. Here is a sample of my data:
test1
Code:
fit.sp<- smooth.spline(test1)
fitted_values <-fit.sp$fit$coef
Error:
Error in smooth.spline(median_weeknum, test1) :
missing or infinite values in inputs are not allowed
Any ideas on how I can fix this?
Upvotes: 2
Views: 3203
Reputation: 159
Thank you! While trying to re post the question I tried the package zoo
. I was using the loop on quite a few data sets. I think the smoothing function was creating knots
around NA
values where it did not find any existing x
value. Using na.spline()
I created values around these zones and it solved the problem!
Upvotes: 1