Cut age into groups.
cutage.Rd
Cut age into groups.
Arguments
- x
Vector contains the ages.
- method
The method to use for age grouping. Options are "interval", "distance", or "quantile".
- length
The length of intervals for age grouping when method is set to "distance".
- maxage
The maximum age for age grouping.
- sep_zero
A logical value indicating whether to include a separate group for age 0.
- breaks
Custom breakpoints for the "interval" method.
- labels
labels for the levels of the resulting category. By default, labels are constructed using "(a,b]" interval notation. If labels = FALSE, simple integer codes are returned instead of a factor.
- lang
Language used for output. Options are 'cn' or 'en'. Default is 'cn.'.
- label_tail
A string to be appended at the end of each label.
- right
A logical value indicating whether the intervals are right-closed or right-open.
Examples
age <- sample(0:101, 200, replace = TRUE)
agegrp <- cutage(age,
method = "distance", length = 5,
maxage = 60, sep_zero = TRUE)
agegrp
#> [1] 60+ 岁 1-4 岁 60+ 岁 55-59 岁 40-44 岁 30-34 岁 15-19 岁 60+ 岁
#> [9] 10-14 岁 30-34 岁 60+ 岁 60+ 岁 60+ 岁 55-59 岁 20-24 岁 5-9 岁
#> [17] 40-44 岁 60+ 岁 55-59 岁 60+ 岁 55-59 岁 60+ 岁 60+ 岁 30-34 岁
#> [25] 40-44 岁 45-49 岁 35-39 岁 15-19 岁 60+ 岁 60+ 岁 60+ 岁 60+ 岁
#> [33] 60+ 岁 5-9 岁 50-54 岁 60+ 岁 35-39 岁 60+ 岁 60+ 岁 60+ 岁
#> [41] 10-14 岁 60+ 岁 15-19 岁 10-14 岁 60+ 岁 30-34 岁 20-24 岁 35-39 岁
#> [49] 60+ 岁 50-54 岁 60+ 岁 25-29 岁 35-39 岁 15-19 岁 50-54 岁 60+ 岁
#> [57] 30-34 岁 25-29 岁 20-24 岁 30-34 岁 60+ 岁 60+ 岁 50-54 岁 30-34 岁
#> [65] 25-29 岁 1-4 岁 15-19 岁 60+ 岁 30-34 岁 45-49 岁 60+ 岁 15-19 岁
#> [73] 60+ 岁 20-24 岁 60+ 岁 60+ 岁 60+ 岁 10-14 岁 40-44 岁 20-24 岁
#> [81] 50-54 岁 15-19 岁 1-4 岁 60+ 岁 60+ 岁 60+ 岁 20-24 岁 20-24 岁
#> [89] 60+ 岁 45-49 岁 10-14 岁 25-29 岁 60+ 岁 20-24 岁 20-24 岁 60+ 岁
#> [97] 5-9 岁 5-9 岁 5-9 岁 1-4 岁 10-14 岁 5-9 岁 10-14 岁 30-34 岁
#> [105] 15-19 岁 60+ 岁 60+ 岁 60+ 岁 10-14 岁 5-9 岁 60+ 岁 60+ 岁
#> [113] 60+ 岁 60+ 岁 60+ 岁 60+ 岁 25-29 岁 10-14 岁 60+ 岁 60+ 岁
#> [121] 25-29 岁 45-49 岁 25-29 岁 60+ 岁 60+ 岁 60+ 岁 45-49 岁 60+ 岁
#> [129] 60+ 岁 20-24 岁 60+ 岁 10-14 岁 25-29 岁 5-9 岁 60+ 岁 20-24 岁
#> [137] 40-44 岁 40-44 岁 50-54 岁 60+ 岁 60+ 岁 60+ 岁 30-34 岁 60+ 岁
#> [145] 5-9 岁 60+ 岁 55-59 岁 25-29 岁 30-34 岁 40-44 岁 60+ 岁 50-54 岁
#> [153] 50-54 岁 40-44 岁 10-14 岁 25-29 岁 60+ 岁 60+ 岁 60+ 岁 40-44 岁
#> [161] 10-14 岁 5-9 岁 40-44 岁 55-59 岁 60+ 岁 60+ 岁 30-34 岁 15-19 岁
#> [169] 60+ 岁 25-29 岁 60+ 岁 55-59 岁 30-34 岁 15-19 岁 60+ 岁 40-44 岁
#> [177] 10-14 岁 60+ 岁 10-14 岁 60+ 岁 60+ 岁 60+ 岁 55-59 岁 60+ 岁
#> [185] 0 岁 15-19 岁 40-44 岁 30-34 岁 60+ 岁 35-39 岁 10-14 岁 40-44 岁
#> [193] 60+ 岁 30-34 岁 20-24 岁 5-9 岁 40-44 岁 60+ 岁 60+ 岁 35-39 岁
#> 14 Levels: 0 岁 1-4 岁 5-9 岁 10-14 岁 15-19 岁 20-24 岁 25-29 岁 ... 60+ 岁