Skip to contents

Split continuous ages to age groups

Usage

ages(x, groups, char)

Arguments

x

Array with numeric values of age

groups

Array with numeric values of lower boundaries of age groups

char

Logical. Should output array be numeric (FALSE) or character (Factor) array (TRUE)

Value

Array with classified ages

Examples

groups <- c(0,1,5,10,15,20, 24, 45, 85)
x <- sample(0:100, 101)
ages(x, groups, FALSE)
#>   [1] 24 20 45 45 45 24 45 45 45  1 20 45 45  1 45 45 24 85 45 85 24 45 24 45 85
#>  [26]  1 85 24 45  5 24 45  5 20  5 45 45 15 45 45 85 85  0  5 45 45 45 45 24 85
#>  [51] 45 24  5 24 45 45 15 24 85 10 24 45 85 85  1 85 45 45 45 85 45 24 45 24 85
#>  [76] 45 10 45 85 45 24 45 24 45 10 45 85 45 15 24 15 10 15 85 24 24 20 24 10 45
#> [101] 24