Add 1-indexed APC columns to data frame, handling numeric or categorical age/period
as.APC.df(data, age, period, age_order = NULL, period_order = NULL, M = 1) The data frame with new columns \code{age_index}, \code{period_index}, \code{cohort_index},
and sorted by \code{(age_index, period_index)}.
Data frame with age and period columns.
Age column in data.
Period column in data.
(Optional) Character vector giving the desired order of age levels.
If NULL and the age column is factor/character, uses unique(sort(data[[age]])).
(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]])).
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).