Determine age class intervals based on a vector of age class lower bounds.

age2int(Age, OAG = TRUE, OAvalue = NA)

Arguments

Age

integer or numeric. Vector of lower age group bounds .

OAG

logical. Whether or not the final age group is open. Default TRUE.

OAvalue

numeric or integer. The value to use for the final age interval if OAG = TRUE. Default NA.

Value

Age interval vector, of same length as Age.

Details

If the final age group is open, it is given a value of NA by default, or else a user-determined value. If the final age group is closed, it is assumed to be equal to the next-lower interval. If the final age interval is known and not equal to the next lowest interval, specify OAG = TRUE and assign its value to OAvalue.

Examples

# single age examples: Age <- 0:100 age2int(Age, OAG = TRUE, OAvalue = NA)
#> [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 #> [26] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 #> [51] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 #> [76] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 #> [101] NA
age2int(Age, OAG = TRUE, OAvalue = Inf)
#> [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 #> [19] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 #> [37] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 #> [55] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 #> [73] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 #> [91] 1 1 1 1 1 1 1 1 1 1 Inf
age2int(Age, OAG = FALSE)
#> [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 #> [38] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 #> [75] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
# and for abridged ages: AgeA <- c(0,1,seq(5,85,by=5)) age2int(AgeA, OAG = TRUE, OAvalue = NA)
#> [1] 1 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 NA
age2int(AgeA, OAG = TRUE, OAvalue = Inf)
#> [1] 1 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 Inf
age2int(AgeA, OAG = FALSE)
#> [1] 1 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5