calcAgeN: Calculate which large age group single ages belong to.

View source: R/utilsAge.R

calcAgeNR Documentation

Calculate which large age group single ages belong to.

Description

Assign single ages to age groups of equal and arbitrary width, and also optionally shifted.

Usage

calcAgeN(Age, N = 5, shiftdown = 0)

Arguments

Age

integer. Vector of single ages (lower bound).

N

integer. Desired width of resulting age groups.

shiftdown

integer. Move the grouping down by one or more single ages. Optional argument.

Details

If you shift the groupings, then the first age groups may have a negative lower bound (for example of -5). These counts would be discarded for the oscillatory version of Sprague smoothing, for example, but they are preserved in this function. The important thing to know is that if you shift the groups, the first and last groups won't be N years wide. For example if shiftdown is 1, the first age group is 4-ages wide.

Value

An integer vector of length(Age) indicating the age group that each single age belongs to.

Examples

Age <- 0:100
calcAgeN(Age)
calcAgeN(Age, N = 4)
calcAgeN(Age, N = 3)
calcAgeN(Age, shiftdown = 1)
calcAgeN(Age, shiftdown = 2)
# can be used to group abridged into equal 5-year intervals
AgeAbr <- c(0,1,5,10,15,20)
calcAgeN(AgeAbr)

timriffe/DemoTools documentation built on Oct. 14, 2024, 12:53 p.m.