AGEN: Trim two age vectors to matching N-year age groups.

View source: R/utilsAge.R

AGENR Documentation

Trim two age vectors to matching N-year age groups.

Description

Determining which N-year (e.g. 5-year) age groups two vectors have in common is helpful for matching vector lengths, and questions of alignment. Used as a utility throughout.

Usage

AGEN(
  Age1,
  Age2,
  N = 5,
  consecutive = TRUE,
  ageMin = 0,
  ageMax = max(c(Age1, Age2))
)

Arguments

Age1

integer. Vector of first age groups (lower bounds).

Age2

integer. Vector of second age groups (lower bounds).

N

integer. Target age group interval (just one number).

consecutive

logical. Whether or not to throw error if resulting age groups not consecutive. Default TRUE.

ageMin

integer. Optional lower age bound for output.

ageMax

integer. Optional upper age bound for output.

Value

Integer vector of the N-year age groups present in both Age1 and Age2.

Examples

Age1 <- seq(0, 100, by = 5)
Age2 <- 0:80
AGEN(Age1, Age2, N = 5)
AGEN(Age1, Age2, N = 5, ageMax = 70)

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