vselect: Select vector with tidyselect functions

View source: R/tidy-select-leverage.R

vselectR Documentation

Select vector with tidyselect functions

Description

A wrapper around the tidyselect functions that allows to use them not only on data.frames but on vectors as well.

Usage

vselect(input, ..., out.fail = base::character(0))

lselect(lst, ..., out.fail = base::list())

Arguments

input

A character vector or a factor.

...

Additional selection helpers from the tidyselect package that match names according to a given pattern.

out.fail

Output if no content remains after tidyselection has been tried.

lst

A named list. (Unnamed elements are discarded.)

Value

A subsetted version of the input.

Note

vselect() selects by element. lselect() selects by element name.

See Also

starts_with(), ends_with(), contains(), matches()

Examples


 library(datasets)
 library(confuns)

 vec <- c("apple", "banana", "pineapple", "tomato")

 vselect(vec, contains("apple") | ends_with("o"))

 lst <- list(a = mtcars, ab = iris, ac = cars)

 lselect(lst, starts_with("a") & !ends_with("c"))




kueckelj/confuns documentation built on June 28, 2024, 9:19 a.m.