Filter rows matching a set of criteria
filter_matching.RdFilters `data` by retaining rows whose values match at least one row in `criteria` for the selected columns.
Details
Each row of `criteria` represents a combination of values to match. Multiple rows are therefore combined using OR logic, while values within a row are combined using AND logic.
Examples
data <- data.frame(
x = c(1, 1, 2, 2),
y = c("a", "b", "a", "b"),
z = 1:4
)
filter_matching(
data,
data.frame(x = 1, y = "a")
)
#> x y z
#> 1 1 a 1
filter_matching(
data,
data.frame(
x = c(1, 2),
y = c("a", "b")
)
)
#> x y z
#> 1 1 a 1
#> 2 2 b 4