as.APC.df: Add 1-indexed APC columns to data frame, handling numeric or...

View source: R/export-DataPreprocessing.R

as.APC.dfR Documentation

Add 1-indexed APC columns to data frame, handling numeric or categorical age/period

Description

Add 1-indexed APC columns to data frame, handling numeric or categorical age/period

Usage

as.APC.df(data, age, period, age_order = NULL, period_order = NULL, M = 1)

Arguments

data

Data frame with age and period columns.

age

Age column in data.

period

Period column in data.

age_order

(Optional) Character vector giving the desired order of age levels. If NULL and the age column is factor/character, uses unique(sort(data[[age]])).

period_order

(Optional) Vector (numeric or character) giving the desired order of periods. If NULL and period column is a factor/character, uses unique(sort(data[[period]])).

M

Grid factor, defined as the ratio of age interval width to period interval width. Defaults to 1 (i.e. assuming equal sized age and period increments).

Value

           The data frame with new columns \code{age_index}, \code{period_index}, \code{cohort_index},
                   and sorted by \code{(age_index, period_index)}.

MAPCtools documentation built on June 25, 2025, 5:09 p.m.