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
Firstly thank you so much for creating this package, I am very thankful.
I have a situation where I want to check that values in a column a must be one of the values in columns b and c. Based on the data frame in the following reprex, I would expect rows 2, 4, and 5 to be in violation of such rule defined with the %in% operator, but that is not the case.
library(validate)
example_df<-tibble::tribble(
~a, ~b, ~c,
"a", "a", "b", # a exists in b, c"a", "x", "z", # a does not exist in b, c"a", "a", NA_character_, # a exists in b, c but one of them is NA"a", "x", NA_character_, # a does not exist in b, c but one of them is NA,NA_character_, "a", "x", # a is NA but not NA in b and cNA_character_, NA_character_, "x"# a is na and b or c is na
)
result<-example_df|> check_that(
a%in% c(b, c)
)
violating(example_df, result)
#> # A tibble: 0 × 3#> # ℹ 3 variables: a <chr>, b <chr>, c <chr>
Firstly thank you so much for creating this package, I am very thankful.
I have a situation where I want to check that values in a column
a
must be one of the values in columnsb
andc
. Based on the data frame in the following reprex, I would expect rows 2, 4, and 5 to be in violation of such rule defined with the%in%
operator, but that is not the case.Created on 2023-11-04 with reprex v2.0.2
I am aware that I can simulate the
%in%
operator withBut this would get too hard to maintain as the number of columns grows.
What is the recommended way to write such a check ?
Thanks
The text was updated successfully, but these errors were encountered: