For each desired row, check if all/any/none of the columns fulfill a given comparison, return the index of the first column that fulfills the comparison, or the number of columns that do.
row_compare(.data, match_type = "none", operator = "==", values = 0L, ...) # S3 method for matrix row_compare(.data, match_type = "none", operator = "==", values = 0L, ...) # S3 method for data.frame row_compare(.data, match_type = "none", operator = "==", values = 0L, ...)
| .data | A two-dimensional data structure. |
|---|---|
| match_type | One of ("all", "any", "none", "which_first", "count"). Possibly abbreviated. |
| operator | A character indicating the comparison operator. See details. |
| values | The value or list of values to compare against. See details. |
| ... | Arguments passed on to
|
The character in operator should match one of the base::Comparison operators. You can also
pass "is", which is an alias for "==", but might convey code semantics better in case values
contain NA or Inf.
If values is not a list, it will be coerced to one with base::as.list(). Each element in the
list must have length equal to 1. The values are recycled in order to match the number of columns
in .data.
Type promotion/conversion will follow normal R rules.
The na_action from op_ctrl() is only relevant when a value from values is not NA.
Note that string comparison follows C++ rules.
#> [1] TRUErow_compare(data.frame(NA_integer_, NA_real_, NA_character_, NA, NA_complex_), "all", "is", values = NA)#> [1] TRUE