filter: Return rows with matching conditions

Description Usage Arguments Value Useful filter functions Examples

View source: R/filter.R

Description

Use filter() to choose rows/cases where conditions are TRUE.

Usage

1
filter(.data, ..., .preserve = FALSE)

Arguments

.data

A data.frame.

...

Logical predicated defined in terms of the variables in .data. Multiple conditions are combined with &. Arguments within ... are automatically quoted and evaluated within the context of the data.frame.

.preserve

logical(1). Relevant when the .data input is grouped. If .preserve = FALSE (the default), the grouping structure is recalculated based on the resulting data, otherwise the grouping is kept as is.

Value

A data.frame.

Useful filter functions

Examples

1
2
3
4
5
filter(mtcars, am == 1)
mtcars %>% filter(cyl == 4)
mtcars %>% filter(cyl <= 5 & am > 0)
mtcars %>% filter(cyl == 4 | cyl == 8)
mtcars %>% filter(!(cyl %in% c(4, 6)), am != 0)

poorman documentation built on March 28, 2021, 5:05 p.m.