Description Usage Arguments Details Value Examples
Gets population counts by age for any country using a 2-letter country code, as provided by the US Census international data. Updated in 2018 to handle https and URL change.
1 2 | get_pop_by_age(countries, years, ages = 15, agg = "separate",
rvalue = -1L)
|
countries |
Uses gsub on URL. Can be vector of names (eg, c("US", "UK") and will group into region if A=aggregate. |
years |
Uses gsub on URL. Can be vector (eg, c(2015,2016,2017,2018)) and will stack years |
ages |
is set at 10 for 5 year age groups and 15 for 1 year age groups (default) |
agg |
This defaults to "separate" at the moment (other option is "aggregate"). |
rvalue |
R = 1 or -1 (Need to check this one for what it does. Set at -1 for now.) |
Derived from original code at https://raw.githubusercontent.com/walkerke/teaching-with-datavis/master/pyramids/rcharts_pyramids.R
Results in a dataframe with one row per age. Note that even with 1 year ages, 85 is 85-89, 90 is 90-94, 95 is 95-99, and 100 is 100 and older.
1 2 3 4 5 | ## Not run:
pop1 <- get_pop_by_age("US", 2017)
saveRDS(pop1, "./data/analysis/us_2017_1yr.rds")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.