inst/analysis/scripts/population.R

require(data.table)
require(wpp2022)
require(countrycode)

.args <- if (interactive()) c(
  file.path("input", "population.rds")
) else commandArgs(trailingOnly = TRUE)

data("popAge1dt")
density_dt <- popAge1dt[
  year == 2021, .(
    iso3 = countrycode(country_code, "iso3n", "iso3c", warn = FALSE),
    from = age, weight = pop
  )
][!is.na(iso3)]

density_dt |> saveRDS(tail(.args, 1))

Try the paramix package in your browser

Any scripts or data that you put into this service are public.

paramix documentation built on June 10, 2025, 5:14 p.m.