Description Calculate ages, periods, and cohorts from dates Cleaning existing labels Making labels complete and consistent Other tasks Example workflows
Prepare demographic data for subsequent analysis, focusing particularly on the specification of age groups, periods, and cohorts.
The following functions calculate ages, cohorts, and periods from dates.
age | period | cohort |
date_to_age_year | date_to_period_year | date_to_cohort_year |
date_to_age_quarter | date_to_period_quarter | date_to_cohort_quarter |
date_to_age_month | date_to_period_month | date_to_cohort_month |
demprep also has functions for calculating Lexis triangles from dates. See vignette("demprep")
for a definition of Lexis triangles.
clean_age
, clean_period
,
and clean_cohort
convert
existing age, period, and cohort labels to a standard design.
clean_age_df
, clean_period_df
clean_cohort_df
, is_valid_age
,
is_valid_period
, and is_valid_cohort
can be used to control and check the cleaning-up process.
Labels can be consolidated, and gaps filled in, using the format functions:
age | period | cohort |
format_age_year | format_period_year | format_cohort_year |
format_age_multi | format_period_multi | format_cohort_multi |
format_age_custom | format_period_custom | format_cohort_custom |
format_age_quarter | format_period_quarter | format_cohort_quarter |
format_age_month | format_period_month | format_cohort_month |
format_age_lifetab | ||
format_age_births |
impute_date
and impute_dob
randomly generate in missing dates.
as_date_range_year
,
as_date_range_multi
,
as_date_range_custom
,
as_date_range_quarter
, and
as_date_range_month
create non-standard
but unambiguous period and cohort labels.
flip_to_start
and flip_to_end
help with reformatting one-year period and cohort labels.
Create 5-year age groups and 1-year periods from data with dates
date_to_age_year
and
date_to_period_year
to calculate ages and periods
format_age_multi
and
format_period_year
to create age and period labels
Create 5-year age groups, periods, and cohorts from data with existing age, period, and cohort labels.
clean_age
and clean_period
to tidy original labels
format_age_multi
,
format_period_multi
, and
format_cohort_multi
to form 5-year age groups, periods, and cohorts
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.