This function performs a rowwise match of all supplied values across columns in a data frame. If all of the row values equal one of the supplied values, this function returns an integer 1 (1L) for that row, otherwise it returns an integer 0 (0L).
Arguments
- data
A data frame.
- cols
<
tidy-select> Columns to search across.- values
A list of values to match.
Value
A binary integer vector indicating whether all supplied values were matched with an integer 1 (1L), otherwise it returns an integer 0 (0L).
Details
Parallelization is supported via purrr::in_parallel().
Examples
library(dplyr, warn.conflicts = FALSE)
a <- tibble(
x = 1:3,
y = rep(NA, 3),
z = letters[1:3],
aa = rep(FALSE, 3)
)
val <- list(1, NA, "a", FALSE)
val2 <- list(3, NA, "c", FALSE)
gen_rowall(a, values = val)
#> [1] 1 0 0
b <- a %>%
mutate(
q = gen_rowall(., values = val),
r = gen_rowall(., values = val2)
)
b
#> # A tibble: 3 × 6
#> x y z aa q r
#> <int> <lgl> <chr> <lgl> <int> <int>
#> 1 1 NA a FALSE 1 0
#> 2 2 NA b FALSE 0 0
#> 3 3 NA c FALSE 0 1
