Description Usage Arguments Details Value See Also Examples
Given a vector of age group labels, create a factor
that contains
levels for all ages between the minimum and maximum ages
for reproduction.
1 2 3 4 5 6 7 8 | format_age_births(
x,
break_min = 15,
break_max = 50,
width = 5,
recode_up = FALSE,
recode_down = FALSE
)
|
x |
A vector of age group labels. The age of the parent at the time of the birth of the child. |
break_min |
An integer or |
break_max |
An integer or |
width |
The width in years of the age groups to be created. A positive integer defaulting to 5. |
recode_up |
If |
recode_down |
If |
The minimum and maximum ages for reproduction are specified
via arguments break_min
and break_max
.
If, for instance,
break_min
is 15
and break_max
is 50
, then all births are assumed to
occur to women aged 15 to 49 (inclusive).
If break_min
or break_max
is set to NULL
,
rather than to a specific value, then format_age_births
finds the narrowest range that accommodates the values
in x
.
Datasets sometimes contain a few births to parents
younger than the assumed minimum age of reproduction,
or births to parents older than the assumed maximum age
of reproduction. Demographers often recode ages outside
the expected range so that they fall just within the
expected range. This recoding can be justified
on the grounds that some of the original ages may have
been misreported, but it also alleviates any problems
with tabulations having small counts at extreme ages.
Recoding of parents' ages outside the expected range
is controlled by parameters recode_up
and recode_down
. The default
is for no recoding to occur.
If x
contains NA
, then the
levels of the factor created by format_age_births
also contain NA
.
A factor with the same length as x
.
Other functions for creating age groups are
format_age_year
format_age_multi
format_age_lifetab
format_age_custom
format_age_quarter
format_age_month
date_to_age_year
calculates
ages from dates.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | format_age_births(x = c(22, 34, 19))
format_age_births(x = c("20-24", "37", NA, "32", "21-24"))
format_age_births(x = c("20-24", "37", "32", "21-24"),
width = 10,
break_min = 20)
format_age_births(x = c(20, 37, 15),
width = 1,
break_max = 45)
## allow youngest and oldest age groups to be
## determined by the data
format_age_births(x = c("21", "33", "22-24"),
break_min = NULL,
break_max = NULL)
## recode ages outside the expected range
format_age_births(x = c("22", "13-14", "55", "10-19"),
recode_up = TRUE,
recode_down = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.