na.locf(x, option = "locf", na.remaining = "rev")
na.interpolation
,
na.kalman
,
na.ma
, na.mean
,
na.random
, na.replace
,
na.seadec
, na.seasplit
#Prerequisite: Create Time series with missing values
x <- ts(c(NA,3,4,5,6,NA,7,8))
#Example 1: Perform LOCF
na.locf(x)
#Example 2: Perform NOCF
na.locf(x, option = "nocb")
#Example 3: Perform LOCF and remove remaining NAs
na.locf(x, na.remaining = "rm")
Run the code above in your browser using DataLab