Completes a panel so every country has every year, optionally filling missing
values by carry-forward ("locf") or linear interpolation ("linear") so
animations do not flicker on missing years.
Usage
complete_years(
data,
years = NULL,
value = NULL,
method = c("none", "locf", "linear")
)Value
A completed (and optionally filled) panel tibble – or an sf
frame, if data was one; each invented row carries its country's geometry.
Examples
df <- data.frame(iso3c = "USA", year = c(2000L, 2002L), gdp = c(1, 3))
complete_years(df, 2000:2002, method = "linear")
#> # A tibble: 3 × 3
#> year iso3c gdp
#> <int> <chr> <dbl>
#> 1 2000 USA 1
#> 2 2001 USA 2
#> 3 2002 USA 3
