Skip to contents

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 by as.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 for regexpr, gregexpr and regexec.

.cols

<tidy-select> Columns to transform. You can't select grouping columns because they are already automatically handled by the verb (i.e. summarise() or mutate()).

ignore.case

if FALSE, the pattern matching is case sensitive and if TRUE, case is ignored during matching.

Value

A data frame with relocated columns at first

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