check_age {poputils}R Documentation

Validity Checks for Age Labels

Description

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.

Usage

check_age(x, complete = FALSE, unique = FALSE, zero = FALSE, open = FALSE)

Arguments

x

A vector of age labels.

complete

If TRUE, test whether x has gaps.

unique

If TRUE, test whether x has duplicates.

zero

If TRUE, test whether youngest age group in x starts at 0.

open

If TRUE, test whether oldest age group in x is open.

Details

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:

Value

TRUE, invisibly, or raises an error if a test fails.

See Also

Examples

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)
)

[Package poputils version 0.3.1 Index]