populaR provides a convenient interface to the UN’s World Population Prospects API. Several pre-baked datasets are included, as well as a convenient wrapper for more advanced API users
Installation
You can install the development version of populaR from GitHub with:
# install.packages("devtools")
devtools::install_github("chitrams/populaR")
Example
First you have to get the numeric ID of a location
library(populaR)
get_id("Australia", type = "locations")
#> Iterating ■■■ 5% | ETA: 29sIterating ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 1s
#> # A tibble: 5 × 6
#> id name iso3 iso2 longitude latitude
#> <int> <chr> <chr> <chr> <dbl> <dbl>
#> 1 36 Australia AUS AU 134. -25.3
#> 2 927 Australia/New Zealand ANZ ZL NA NA
#> 3 1834 Australia/New Zealand ANZ ZL NA NA
#> 4 1835 Oceania (excluding Australia and New Zealand) OCA OZ NA NA
#> 5 5502 Europe, Northern America, Australia, and New Zealand SDG SD NA NA