select_if {dplyr} | R Documentation |
This verb is analogous to summarise_if()
and
mutate_if()
in that it lets you use a predicate on
the columns of a data frame. Only those columns for which the
predicate returns TRUE
will be selected.
select_if(.data, .predicate, ...)
.data |
A local tbl source. |
.predicate |
A predicate function to be applied to the columns
or a logical vector. The columns for which |
... |
Additional arguments passed to |
Predicates can only be used with local sources like a data frame.
iris %>% select_if(is.factor) iris %>% select_if(is.numeric) iris %>% select_if(function(col) is.numeric(col) && mean(col) > 3.5)