You can filter multiple rows in one column using the %in%
operator with the filter()
function from the dplyr package. Here's an example:
Suppose you have a data frame df
with a column col
and you want to filter all rows where col
equals a list of values list_vals
. You can do:
main.r113 chars7 lines
This will return a new data frame df_filtered
with only the rows of df
where col
equals "value1"
, "value2"
, or "value3"
.
gistlibby LogSnag