# 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")
# Example 4: Perform linear interpolation, with additional parameter pass through from spline()
# Take a look at the 'Details' section of the na_interpolation documentation
# for more information about advanced parameter pass through options
na_interpolation(x, option ="spline", method ="natural")
# Example 5: Same as example 1, just written with pipe operator
x %>% na_interpolation()
# Example 6: Same as example 2, just written with pipe operator
x %>% na_interpolation(option = "spline")
Run the code above in your browser using DataLab