# NOT RUN {
# 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")
# Example 4: Same as example 1, just written with pipe operator
x %>% na_locf()
# }
Run the code above in your browser using DataLab