# Prerequisite: Create Time series with missing values
x <- ts(c(2, 3, NA, 5, 6, NA, 7, 8))
# Example 1: Replace all NAs by random values that are between min and max of the input time series
na_random(x)
# Example 2: Replace all NAs by random values between 1 and 10
na_random(x, lower_bound = 1, upper_bound = 10)
# Example 3: Same as example 1, just written with pipe operator
x %>% na_random()
Run the code above in your browser using DataLab