filter

0th

Percentile

Return rows with matching conditions.

Return rows with matching conditions.

Usage
filter(.data, ...)

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

Arguments
.data
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 &.
.dots
Used to work around non-standard evaluation. See vignette("nse") for details.
Value

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, arrange_; mutate, mutate_, transmute, transmute_; rename, rename_, select, select_; slice, slice_; summarise, summarise_, summarize, summarize_

Aliases
  • filter
  • filter_
Examples
filter(mtcars, cyl == 8)
filter(mtcars, cyl < 6)
Documentation reproduced from package dplyr, version 0.3, License: MIT + file LICENSE

Community examples

muhammadhu.aiman@gmail.com at Mar 1, 2020 dplyr v0.7.8

`# Filter like contains` Can be used with grep to filter like wildcard or contain statement. Example will return the country names that contains "aldiv" in name column, in this case names like "Maldives" `filter(countries, grepl("aldiv", name, fixed = TRUE)) `

lpy199454@gmail.com at Jul 3, 2018 dplyr v0.7.6

# Remove align level comics <- comics %>% filter(align != "Reformed Criminals") %>% droplevels()

smitaudgata@gmail.com 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) ```