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, mutate, select, slice, summarise

Aliases
  • filter
  • filter_
Examples
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

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) ```