Ayushi Kachhara
Ayushi Kachhara

Reputation: 159

Error in smooth.spline: missing or infinite values in inputs are not allowed

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

Answers (1)

Ayushi Kachhara
Ayushi Kachhara

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

Related Questions