Skip to content

select_helpers accept character vector? #50

@ruaridhw

Description

@ruaridhw

Possible feature request though this may contradict #49

Allow for natively passing a vector of strings to starts_with, ends_with, contains ... in order to avoid having to redefine the regex

Currently:
(1) Unwieldy manual list of single columns

select(df,
       starts_with("a"),
       starts_with("b"),
       ends_with("c"),
       ends_with("d"),
       ...)

or

(2) Redefine matching regex for each select_helper

long_list_of_select_vars <- c("a", "b", ...)
another_long_vector <- c("c", "d", ...)
select(df,
       matches(paste0("^(", paste(long_list_of_select_vars, collapse="|"), ")")),
       matches(paste0("(", paste(another_long_vector, collapse="|"), ")$")))

Request:

select(df,
       starts_with(c("a", "b")),
       ends_with(c("c", "d")),
       ...)

which would have the same behaviour as (1)

For context

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancementhelpers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions