You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#> In dataset 'wrong_data.csv' found 1 warnings and 1 errors
```
one would expect check_data to abort parsing when a data point/observation/row fails verification. However, this doesn't seem to be the implemented behavior, which relies on warnings and/or errors being thrown instead. To illustrate my point, see the following reprex.
renv::use("DavZim/dataverifyr")
renv::use("dplyr@1.1.3")
renv::use("magrittr@2.0.3")
library(dataverifyr)
library(magrittr)
rules <- ruleset(
rule(mpg > 10 & mpg < 30), # mpg goes up to 34
rule(cyl %in% c(4, 8)), # missing 6 cyl
rule(vs %in% c(0, 1), allow_na = TRUE)
)
# stop parsing data when verification fails
read_custom <- function(file, rules) {
data <- readr::read_csv(file) # or however you read in your data
# expected: if the check_data detects a fail: the read_custom function will stop
check_data(data, rules, fail_on_error = TRUE, fail_on_warn = TRUE)
data
}
data_pass <- mtcars %>%
dplyr::filter(mpg > 10 & mpg < 30, cyl %in% c(4, 8))
data_fail <- mtcars %>%
dplyr::filter(cyl == 6)
readr::write_csv(data_pass, "data_pass.csv")
readr::write_csv(data_fail, "data_fail.csv")
# nothing happens when the data matches the rules
read_custom("data_pass.csv", rules)
# this one should fail, but doesn't
read_custom("data_fail.csv", rules)
# no warning/error returned (expected)
data <- readr::read_csv("data_fail.csv")
check_data(data, rules)
Let me know if this makes sense and/or if I'm missing something. Thank you!
Thanks for pointing this out. There was indeed a logical error, as fail_on_error would only stop when an error was thrown in one of the rule evaluations. I have changed the names of the argument to stop_on_error etc, and added stop_on_fail to make the functionality more obvious.
Thank you very much, @DavZim. I tested the latest devel version and I confirm it now works as expected. I find the new argument names more informative and clearly scoped. Thanks!
Hi @DavZim,
in the following example from the README
dataverifyr/README.md
Lines 157 to 176 in f0e718f
one would expect
check_data
to abort parsing when a data point/observation/row fails verification. However, this doesn't seem to be the implemented behavior, which relies on warnings and/or errors being thrown instead. To illustrate my point, see the following reprex.Let me know if this makes sense and/or if I'm missing something. Thank you!
Finally, also note that
dataverifyr/README.md
Line 164 in f0e718f
xname
no longer an argument).The text was updated successfully, but these errors were encountered: