get_pop_by_age: Get Census Counts for Any Country

Description Usage Arguments Details Value Examples

Description

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.

Usage

1
2
get_pop_by_age(countries, years, ages = 15, agg = "separate",
  rvalue = -1L)

Arguments

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.)

Details

Derived from original code at https://raw.githubusercontent.com/walkerke/teaching-with-datavis/master/pyramids/rcharts_pyramids.R

Value

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.

Examples

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)

outcomesinsights/seer.tools documentation built on May 24, 2019, 5:54 p.m.