Fill missing values in a time series (or in a column of a longitudinal data set) with the approximation method.

na_approx(indicator)

Arguments

indicator

A tibble created by get_eurostat_indicator. with time, geo, value, frequency, estimate and method columns.

Value

A tibble updated with with approximated values.

See also

Other approximation functions: impute_indicators(), na_locf(), na_nocb()

Examples

{ example_df <- data.frame ( time = rep(as.Date (paste0(2018:2021, "-01-01")),3), geo = c( rep("NL", 4), rep("BE", 4), rep("LU", 4)), value = c(10,11, NA_real_, 12, NA_real_, 21,22,23, 5,6,7,NA_real_), frequency = rep("A", 12) ) example_df$method <- ifelse(is.na(example_df$value), "missing", "actual") example_df$estimate <- example_df$method na_approx ( example_df ) }
#> # A tibble: 12 x 6 #> time frequency geo value estimate method #> <date> <chr> <chr> <dbl> <chr> <chr> #> 1 2018-01-01 A NL 10 actual actual #> 2 2018-01-01 A BE NA missing missing #> 3 2018-01-01 A LU 5 actual actual #> 4 2019-01-01 A NL 11 actual actual #> 5 2019-01-01 A BE 21 actual actual #> 6 2019-01-01 A LU 6 actual actual #> 7 2020-01-01 A NL 11.5 approx approx #> 8 2020-01-01 A BE 22 actual actual #> 9 2020-01-01 A LU 7 actual actual #> 10 2021-01-01 A NL 12 actual actual #> 11 2021-01-01 A BE 23 actual actual #> 12 2021-01-01 A LU NA missing missing