R/demprep-package.R

#' demprep: Prepare demographic data
#'
#' Prepare demographic data for subsequent analysis,
#' focusing particularly on the specification of
#' age groups, periods, and cohorts.
#'
#' @section Calculate ages, periods, and cohorts from dates:
#'
#' The following functions calculate ages, cohorts, and periods from dates.
#' \tabular{lll}{
#'   \strong{age} \tab \strong{period} \tab \strong{cohort} \cr
#'   \code{\link{date_to_age_year}} \tab \code{\link{date_to_period_year}} \tab \code{\link{date_to_cohort_year}} \cr
#'   \code{\link{date_to_age_quarter}} \tab \code{\link{date_to_period_quarter}} \tab \code{\link{date_to_cohort_quarter}} \cr
#'   \code{\link{date_to_age_month}} \tab \code{\link{date_to_period_month}} \tab \code{\link{date_to_cohort_month}} \cr
#' }
#'
#' demprep also has functions for calculating Lexis triangles from dates. See \code{vignette("demprep")} for a definition of Lexis triangles.
#'
#' @section Cleaning existing labels:
#'
#' \code{\link{clean_age}}, \code{\link{clean_period}},
#' and \code{\link{clean_cohort}} convert
#' existing age, period, and cohort labels to a standard design.
#'
#' \code{\link{clean_age_df}}, \code{\link{clean_period_df}}
#' \code{\link{clean_cohort_df}},  \code{\link{is_valid_age}}, 
#' \code{\link{is_valid_period}}, and \code{\link{is_valid_cohort}}
#' can be used to control and check the cleaning-up process.
#'
#' @section Making labels complete and consistent:
#' 
#' Labels can be consolidated, and gaps filled in, using the format functions:
#'
#' \tabular{lll}{
#'   \strong{age} \tab \strong{period} \tab \strong{cohort} \cr
#'   \code{\link{format_age_year}} \tab \code{\link{format_period_year}} \tab \code{\link{format_cohort_year}} \cr
#'   \code{\link{format_age_multi}} \tab \code{\link{format_period_multi}} \tab \code{\link{format_cohort_multi}} \cr
#'   \code{\link{format_age_custom}} \tab \code{\link{format_period_custom}} \tab \code{\link{format_cohort_custom}} \cr
#'   \code{\link{format_age_quarter}} \tab \code{\link{format_period_quarter}} \tab \code{\link{format_cohort_quarter}} \cr
#'   \code{\link{format_age_month}} \tab \code{\link{format_period_month}} \tab \code{\link{format_cohort_month}} \cr
#'   \code{\link{format_age_lifetab}} \tab  \tab \cr
#'   \code{\link{format_age_births}} \tab  \tab
#' }
#'
#'
#' @section Other tasks:
#'
#' \code{\link{impute_date}} and \code{\link{impute_dob}}
#' randomly generate in missing dates.
#'
#' \code{\link{as_date_range_year}}, 
#' \code{\link{as_date_range_multi}}, 
#' \code{\link{as_date_range_custom}}, 
#' \code{\link{as_date_range_quarter}}, and
#'  \code{\link{as_date_range_month}} create non-standard
#' but unambiguous period and cohort labels.
#'
#' \code{\link{flip_to_start}} and \code{\link{flip_to_end}}
#' help with reformatting one-year period and cohort labels. 
#' 
#' 
#' @section Example workflows:
#'
#' Create 5-year age groups and 1-year periods from data with dates
#' 
#' \itemize{
#'   \item \code{\link{date_to_age_year}} and
#'    \code{\link{date_to_period_year}}
#'   to calculate ages and periods
#'   \item \code{\link{format_age_multi}} and
#'    \code{\link{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.
#'
#' \itemize{
#'   \item \code{\link{clean_age}} and \code{\link{clean_period}}
#'   to tidy original labels
#'   \item  \code{\link{format_age_multi}}, 
#'    \code{\link{format_period_multi}}, and
#'    \code{\link{format_cohort_multi}}
#'   to form 5-year age groups, periods, and cohorts
#' }
#'
#' @docType package
#' @name demprep
NULL
bayesiandemography/demprep documentation built on Dec. 28, 2021, 8:47 a.m.