age_lower {poputils} | R Documentation |
Lower Limits, Midpoints, and Upper Limits of Age Groups
Description
Given a vector x
of age group labels, return
a numeric vector.
-
age_lower()
returns the lower limits of each age group, -
age_mid()
returns the midpoints, and -
age_upper()
returns the upper limits.
Vector x
must describe 1-year, 5-year or life-table
age groups: see age_labels()
for examples. x
can
format these age groups in any way understood by
reformat_age()
.
Usage
age_lower(x)
age_mid(x)
age_upper(x)
Arguments
x |
A vector of age group labels. |
Details
These functions can make age groups easier to work with. Lower and upper limits can be used for selecting on age. Replacing age group with midpoints can improve graphs.
Value
A numeric vector, the same length as x
.
See Also
Examples
x <- c("15-19", "5-9", "50+")
age_lower(x)
age_mid(x)
age_upper(x)
## non-standard formats are OK
age_lower(c("infants", "100 and over"))
df <- data.frame(age = c("1-4", "10-14", "5-9", "0"),
rate = c(0.023, 0.015, 0.007, 0.068))
df
subset(df, age_lower(age) >= 5)
[Package poputils version 0.3.1 Index]