Check if a row's columns' values are present in a set of known values
row_in(.data, match_type = "none", sets = list(), negate = FALSE, ...) # S3 method for matrix row_in(.data, match_type = "none", sets = list(), negate = FALSE, ...) # S3 method for data.frame row_in(.data, match_type = "none", sets = list(), negate = FALSE, ...)
.data | A two-dimensional data structure. |
---|---|
match_type | One of ("all", "any", "none", "which_first", "count"). Possibly abbreviated. |
sets | The list of sets to compare against. See details. |
negate | Logical. If |
... | Arguments passed on to
|
The sets
are recycled in order to match the number of columns in .data
.
Type promotion/conversion will follow normal R rules.
Note that string comparison follows C++ rules.
mat <- matrix(sample(letters, 10), nrow = 5L, ncol = 2L) # count how many columns are in a chosen subset row_in(mat, "count", list(c("a", "b")))#> [1] 0 0 0 0 0# careful if complex numbers are involved row_in(data.frame(-1 + 0i, 1/3 + 0i), "all", list(-1L, 1/3))#> [1] TRUE#> [1] TRUE