data-cleaning / errorlocate

Find and replace erroneous fields in data using validation rules
http://data-cleaning.github.io/errorlocate/
21 stars 3 forks source link

out domain error for categorical variable not working for single variable #25

Closed nickforr closed 3 years ago

nickforr commented 3 years ago

Similar to #14 but when the comparison is a single element the wrong answer seems to be returned.

library(errorlocate)
rules <- validator( x %in% c("A"))
data <- data.frame(x = "C")
locate_errors(data, rules)$errors

This returns FALSE but should return TRUE. For completeness, the example used in #14 is:

rules <- validator( x %in% c("A", "B"))
data <- data.frame(x = "C")
locate_errors(data, rules)$errors

which returns TRUE.

Using errorlocate version 0.4 on R 3.6.3 on Windows.

Incidentally, the following seems to work:

rules <- validator( x %in% c("A", "A"))
data <- data.frame(x = "C")
locate_errors(data, rules)$errors
edwindj commented 3 years ago

Thanks for reporting! I will have a look at it asap.

edwindj commented 3 years ago

In my tests this is solving the issue, could you please check if it is working for you?

remotes::install_github("data-cleaning/errorlocate")

If it is working I will update CRAN in a week or so. (CRAN does not like high frequency updates :-) )

edwindj commented 3 years ago

Closing issue, please reopen if necessary...

nickforr commented 3 years ago

Working perfectly, thanks for speedy fix. And thanks for this and validate, really easy to use and very helpful.