filter_keys | R Documentation |
If filters
is NULL
, no filtering is done.
Otherwise, the .data
object is filtered via an inner_join()
using all columns of the filter:
inner_join(.data, filter, by = colnames(filter))
by
and na_by
can overwrite the inner_join()
columns used in the filtering.
filter_keys(.data, filters, by = NULL, na_by = NULL, ...)
.data |
( |
filters |
( |
by |
A join specification created with If To join on different variables between To join by multiple variables, use a
For simple equality joins, you can alternatively specify a character vector
of variable names to join by. For example, To perform a cross-join, generating all combinations of |
na_by |
( |
... |
Further arguments passed to |
An object of same class as .data
# Filtering with null means no filtering is done
filter <- NULL
identical(filter_keys(mtcars, filter), mtcars) # TRUE
# Filtering by vs = 0
filter <- data.frame(vs = 0)
identical(filter_keys(mtcars, filter), dplyr::filter(mtcars, vs == 0)) # TRUE
# Filtering by the specific combinations of vs = 0 and am = 1
filter <- dplyr::distinct(mtcars, vs, am)
filter_keys(mtcars, filter)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.