Format validate_table_content into CLI message
validate_table_content_cli_msg.Rd
Format validate_table_content into CLI message
Arguments
- x
the output of
validate_table_content()
Value
the dataset of x
, throws errors if there are any validation issues
from validate_table_content()
Examples
x <- get_wahis_erf(
disease = "Anthrax",
species = "Cattle",
animal_category = "Domestic",
validate = TRUE # default
)
#> ✔ All data in "emission_risk_factors" valided.
#> ✔ WAHIS emission risk factors dataset has 65 entries for `disease = Anthrax`, `species = Cattle`, and `animal_category = Domestic`.
status <- validate_table_content(x, table_name = "emission_risk_factors")
dataset <- validate_table_content_cli_msg(status)
#> ✔ All data in "emission_risk_factors" valided.
dataset
#> # A tibble: 65 × 18
#> iso3 country disease animal_category species disease_notification
#> <chr> <chr> <chr> <chr> <chr> <int>
#> 1 ALB Albania Anthrax Domestic Cattle 0
#> 2 ARM Armenia Anthrax Domestic Cattle 0
#> 3 CYM Cayman Islands Anthrax Domestic Cattle 0
#> 4 HRV Croatia Anthrax Domestic Cattle 0
#> 5 FLK Falkland Islands … Anthrax Domestic Cattle 0
#> 6 JPN Japan Anthrax Domestic Cattle 0
#> 7 KGZ Kyrgyzstan Anthrax Domestic Cattle 0
#> 8 MEX Mexico Anthrax Domestic Cattle 0
#> 9 RUS Russia Anthrax Domestic Cattle 0
#> 10 SYC Seychelles Anthrax Domestic Cattle 0
#> # ℹ 55 more rows
#> # ℹ 12 more variables: targeted_surveillance <int>, general_surveillance <int>,
#> # screening <int>, precautions_at_the_borders <int>, slaughter <int>,
#> # selective_killing_and_disposal <int>, zoning <int>,
#> # official_vaccination <int>, last_outbreak_end_date <date>,
#> # commerce_illegal <int>, commerce_legal <int>, data_source <chr>
x <- wahis_emission_risk_factors
status <- validate_table_content(x, table_name = "emission_risk_factors")
z <- try(validate_table_content_cli_msg(status), silent = TRUE) # error here if invalid data
message(cli::ansi_strip(z))
#> Error in validate_table_content_cli_msg(status) :
#> ✖ Data validation errors (3) found for "emission_risk_factors":
#> 1. Values for "iso3" has duplicate values
#> 2. Values for "animal_category" has multiple values, each riskintro study
#> should only have one animal category
#> 3. Values for "species" has multiple values, each riskintro study should only
#> have one animal category
wrong_data <- mtcars
wrong_data$slaughter <- as.integer(round(runif(nrow(mtcars))))
wrong_data$last_outbreak_end_date <- "HELLO"
status <- validate_table_content(wrong_data, table_name = "emission_risk_factors")
dataset <- try(validate_table_content_cli_msg(status), silent = TRUE)
message(cli::ansi_strip(z))
#> Error in validate_table_content_cli_msg(status) :
#> ✖ Data validation errors (3) found for "emission_risk_factors":
#> 1. Values for "iso3" has duplicate values
#> 2. Values for "animal_category" has multiple values, each riskintro study
#> should only have one animal category
#> 3. Values for "species" has multiple values, each riskintro study should only
#> have one animal category