Adds a growth-rate column to a panel: either the period-over-period change
("yoy") or the compound annual growth rate from the first observed year
("cagr"), computed per country.
Usage
growth_rate(data, value, type = c("yoy", "cagr"), suffix = "_growth")Examples
df <- data.frame(iso3c = "USA", year = 2000:2002, gdp = c(100, 110, 121))
growth_rate(df, gdp)
#> # A tibble: 3 × 4
#> iso3c year gdp gdp_growth
#> <chr> <int> <dbl> <dbl>
#> 1 USA 2000 100 NA
#> 2 USA 2001 110 0.100
#> 3 USA 2002 121 0.100
