View source: R/validate_tags.R
validate_tags | R Documentation |
This function evaluates the validity of the tags of a linelist
object by
checking that: i) tags are present ii) tags is a list
of character
iii)
that all default tags are present iv) tagged variables exist v) that no extra
tag exists (if allow_extra
is FALSE
).
validate_tags(x, allow_extra = FALSE)
x |
a |
allow_extra |
a |
If checks pass, a linelist
object; otherwise issues an error.
validate_types()
to check if tagged variables have
the right classes
if (require(outbreaks) && require(dplyr) && require(magrittr)) {
## create a valid linelist
x <- measles_hagelloch_1861 %>%
tibble() %>%
make_linelist(
id = "case_ID",
date_onset = "date_of_prodrome",
age = "age",
gender = "gender"
)
x
## validation
validate_tags(x)
## hack to create an invalid tags (missing defaults)
attr(x, "tags") <- list(id = "case_ID")
## the below issues an error
## note: tryCatch is only used to avoid a genuine error in the example
tryCatch(validate_tags(x), error = paste)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.