This function is an auxiliary used by top level functions where it is guaranteed that age groups are standard abridged age groups. If Age is specified, this will work as well for other age groupings.

inferAgeIntAbr(Age, vec, OAG = FALSE, OAvalue = NA)

Arguments

Age

integer. Vector of lower bound of each age group.

vec

Any vector, presumably a count, rate, or similar.

OAG

logical. Whether or not the final age group open. Default FALSE.

OAvalue

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

Value

An integer vector of length(vec) indicating the width of the abridged age group that each vector element corresponds to.

Details

If based solely on the length of a vector, this will give erroneous results if ages are anything other than standard abridged ages groups. If the final age group is open, the interval width is defined as NA. Inf or -1 would have also been a good choice, but we went with NA.

Examples

vec <- runif(20) inferAgeIntAbr(vec = vec)
#> [1] 1 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
inferAgeIntAbr(vec = vec, OAG = TRUE)
#> [1] 1 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 NA
inferAgeIntAbr(Age = 0:100, OAG = TRUE)
#> [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