check_age | R Documentation |
Check that age labels can be parsed and, optionally, whether the labels are complete, unique, start at zero, and end with an open age group.
check_age(
x,
complete = FALSE,
unique = FALSE,
zero = FALSE,
open = FALSE,
closed = FALSE
)
x |
A vector of age labels. |
complete |
If |
unique |
If |
zero |
If |
open |
If |
closed |
If |
By default, check_age()
only tests whether
a set of labels can be parsed as single-year,
five-year, or life table age groups.
(See age_group_type()
for more on the three
types of age group.) However, it can
also apply the following tests:
complete
. Whether x
includes
all intermediate age groups, with no gaps.
For instance, the labels c("10-14", "15-19", "5-9")
are complete, while the labelsc("15-19", "5-9")
are not (because they are missing "10-14"
.)
unique
. Whether x
has duplicated labels.
zero
. Whether the youngest age group in x
starts
at age 0, ie whether it includes "0"
or "0-4"
.
open
. Whether the oldest age group in x
is "open",
with no upper limit, eg "100+"
or "65+"
.
closed
. Whether the oldest age group in x
is "closed", with an upper limit,
eg "100-104+"
or "65"
.
TRUE
, invisibly, or raises an
error if a test fails.
reformat_age()
to convert age labels to
the format used by poputils.
try(
check_age(c("10-14", "0-4", "15+"),
complete = TRUE)
)
try(
check_age(c("10-14", "5-9", "0-4", "5-9", "15+"),
unique = TRUE)
)
try(
check_age(c("10-14", "5-9", "15+"),
zero = TRUE)
)
try(
check_age(c("10-14", "0-4", "5-9"),
open = TRUE)
)
try(
check_age(c("10+", "0-4", "5-9"),
closed = TRUE)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.