Filters a dataset to choose rows where conditions are true.
filter(.df, ..., .by = NULL)
Arguments
- .df
A data.frame or data.table
- ...
Conditions to filter by
- .by
Columns to group by if filtering with a summary function
Examples
df <- tidytable(
a = 1:3,
b = 4:6,
c = c("a", "a", "b")
)
df %>%
filter(a >= 2, b >= 4)
#> # A tidytable: 2 × 3
#> a b c
#> <int> <int> <chr>
#> 1 2 5 a
#> 2 3 6 b
df %>%
filter(b <= mean(b), .by = c)
#> # A tidytable: 2 × 3
#> a b c
#> <int> <int> <chr>
#> 1 1 4 a
#> 2 3 6 b