validate_types {linelist} | R Documentation |
Check tagged variables are the right class
Description
This function checks the class of each tagged variable in a linelist
against pre-defined accepted classes in tags_types()
.
Usage
validate_types(x, ref_types = tags_types())
Arguments
x |
a |
ref_types |
a |
Value
A named list
.
See Also
-
tags_types()
to change allowed types -
validate_tags()
to perform a series of checks on the tags -
validate_linelist()
to combinevalidate_tags
andvalidate_types
Examples
if (require(outbreaks) && require(dplyr) && require(magrittr)) {
## create an invalid linelist - gender is a numeric
x <- measles_hagelloch_1861 %>%
tibble() %>%
make_linelist(
id = "case_ID",
gender = "infector"
)
x
## the below would issue an error
## note: tryCatch is only used to avoid a genuine error in the example
tryCatch(validate_types(x), error = paste)
## to allow other types, e.g. gender to be integer, character or factor
validate_types(x, tags_types(gender = c("integer", "character", "factor")))
}
[Package linelist version 1.1.4 Index]