is_yr: Validation functions for 'yr' objects

View source: R/s3-yr.R

is_yrR Documentation

Validation functions for yr objects

Description

Tests whether an object is a vector of years with an era (a yr object). is_yr() tests whether the object inherits from the S3 class era_yr. is_valid_yr() performs additional checks to determine whether the object is well-formed (see details). validate_yr() throws an informative error message for invalid yrs.

Usage

is_yr(x)

validate_yr(x)

is_valid_yr(x)

Arguments

x

Object to test.

Details

Valid yr objects:

  • Must contain numeric data (NAs are allowed)

  • Must have the era attribute set and not NA

  • Must not have more than one era

  • Must have an era attribute that is a valid era object (see validate_era())

Value

is_yr() and is_valid_yr() return TRUE or FALSE. validate_yr() returns x invisibly, and is used for its side-effect of throwing an informative error for invalid objects.

See Also

Other era helper functions: era_parameters, era_year_parameters, era_year, era, is_era_year(), is_era(), this_year()

Examples

x <- yr(5000:5050, era("cal BP"))
is_yr(x)
is_valid_yr(x)
validate_yr(x)

era documentation built on Nov. 17, 2022, 5:06 p.m.