Safely select elements of a named object (like a named R list).
Arguments
- x
A object with
names
attribute (usually a named R list);- elements
A vector of strings with the name of the elements to search for;
Details
This functions works in a similar way to dplyr::any_of()
. It tries
to select any element of x
that is in the vector given by the user
in the elements
argument.
In other words, if the user gives the vector c("a", "c", "e")
, select_any_of()
will search for elements "a", "c" and "e" in the x
object, and will select
any of these elements if it finds them.
But dplyr::any_of()
is designed to work with columns of a data.frame,
and figma::select_any_of()
is designed to work specially with elements of a
named list (although it can be used to select columns of a data.frames as well).