Return rows with matching conditions.

Return rows with matching conditions.

filter(.data, ...)

filter_(.data, ..., .dots)


A tbl. All main verbs are S3 generics and provide methods for tbl_df, tbl_dt and tbl_sql.


Logical predicates. Multiple conditions are combined with &.


Used to work around non-standard evaluation. See vignette("nse") for details.


An object of the same class as .data.

Data frame row names are silently dropped. To preserve, convert to an explicit variable.

See Also

Other single.table.verbs: arrange, mutate, select, slice, summarise

  • filter
  • filter_
library(dplyr) filter(mtcars, cyl == 8) filter(mtcars, cyl < 6) # Multiple criteria filter(mtcars, cyl < 6 & vs == 1) filter(mtcars, cyl < 6 | vs == 1) # Multiple arguments are equivalent to and filter(mtcars, cyl < 6, vs == 1)
Documentation reproduced from package dplyr, version 0.5.0, License: MIT + file LICENSE

Community examples at May 14, 2018 dplyr v0.7.3

temp<-filter(starwars, species == "Human") temp

darrel_22 at Jan 16, 2018 dplyr v0.7.3

## Filter based on list of criteria With a long list of criteria on which you want to filter, using "&" can become cumbersome. To filter based on such a list for a given variable you can use the %in% operator: ```r list_of_values <- c("SI1", "SI2") SI_data <- filter(diamonds, clarity %in% list_of_values) ```