Uses either linear, spline or stineman interpolation to replace missing values.
na.interpolation(x, option = "linear", ...)
Vector (vector
) or Time Series (ts
) object (dependent on given input at parameter x)
Missing values get replaced by values of a approx, spline or stinterp interpolation.
Johannesson, Tomas, et al. (2015). "Package stinepack".
na.kalman
, na.locf
,
na.ma
, na.mean
,
na.random
, na.replace
,
na.seadec
, na.seasplit
#Prerequisite: Create Time series with missing values
x <- ts(c(2,3,4,5,6,NA,7,8))
#Example 1: Perform linear interpolation
na.interpolation(x)
#Example 2: Perform spline interpolation
na.interpolation(x, option ="spline")
#Example 3: Perform stine interpolation
na.interpolation(x, option ="stine")
Run the code above in your browser using DataLab