Learn R Programming

excessmort (version 0.8.2)

collapse_age_dist: Callapse age groups into broader ones

Description

Collapse a count or demographic data frame into a broader age strata.

Usage

collapse_age_dist(demo, breaks)

collapse_counts_by_age(counts, breaks)

Value

A age groups represented in `demo` or `counts` are grouped using the new age breaks defined by breaks but containing the populations and counts, if applicable, for age groups defined by `breaks`.

Arguments

demo

A data frame with population sizes for different groups that will be collapsed.

breaks

The new age breaks for the new, broader, age strata.

counts

A data frame with counts and population sizes for different groups that will be collapsed

Examples

Run this code

library(lubridate)
data(cook_records)
## define smaller subset for example
cook_demographics_subset <- cook_demographics[year(cook_demographics$date)==2021, ]
demo <- collapse_age_dist(cook_demographics_subset, 
                          breaks = c(0, 20, 40, 60, 80, Inf))

Run the code above in your browser using DataLab