Determine age class intervals based on a vector of age class lower bounds.
age2int(Age, OAG = TRUE, OAvalue = NA)
Age | integer or numeric. Vector of lower age group bounds . |
---|---|
OAG | logical. Whether or not the final age group is open. Default |
OAvalue | numeric or integer. The value to use for the final age interval if |
Age interval vector, of same length as Age
.
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
.
# 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] NAage2int(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 Infage2int(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#> [1] 1 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 NAage2int(AgeA, OAG = TRUE, OAvalue = Inf)#> [1] 1 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 Infage2int(AgeA, OAG = FALSE)#> [1] 1 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5