View source: R/validate_types.R
validate_types | R Documentation |
This function checks the class of each tagged variable in a linelist
against pre-defined accepted classes in tags_types()
.
validate_types(x, ref_types = tags_types())
x |
a |
ref_types |
a |
A named list
.
tags_types()
to change allowed types
validate_tags()
to perform a series of checks on the tags
validate_linelist()
to combine validate_tags
and validate_types
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")))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.