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.

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)
#> [1] 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80
AGEN(Age1, Age2, N = 5, ageMax = 70)
#> [1] 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70