Adds a column giving each country's value as a share of the (year's) world
total – e.g. share of global emissions or GDP. Operates within year when a
panel is supplied.
Examples
df <- data.frame(iso3c = c("USA", "CHN"), co2 = c(5, 10))
share_of_world(df, co2)
#> # A tibble: 2 × 3
#> iso3c co2 co2_share
#> <chr> <dbl> <dbl>
#> 1 USA 5 0.333
#> 2 CHN 10 0.667
