Shortcut for dplyr::filter()
and stringr::str_detect()
Usage
filter_detect(.data, pattern, .cols = dplyr::everything(), ignore.case = TRUE)
Arguments
- .data
A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). See Methods, below, for more details.
- pattern
character string containing a regular expression (or character string for
fixed = TRUE
) to be matched in the given character vector. Coerced byas.character
to a character string if possible. If a character vector of length 2 or more is supplied, the first element is used with a warning. Missing values are allowed except forregexpr
,gregexpr
andregexec
.- .cols
<
tidy-select
> Columns to transform. You can't select grouping columns because they are already automatically handled by the verb (i.e.summarise()
ormutate()
).- ignore.case
if
FALSE
, the pattern matching is case sensitive and ifTRUE
, case is ignored during matching.
Examples
# don't specify column
dplyr::band_members |>
filter_detect("Beatles")
#> # A tibble: 2 × 2
#> band name
#> <chr> <chr>
#> 1 Beatles John
#> 2 Beatles Paul
# specify columns
dplyr::band_members |>
filter_detect("Beatles", band)
#> # A tibble: 2 × 2
#> band name
#> <chr> <chr>
#> 1 Beatles John
#> 2 Beatles Paul