fselect: Fast 'dplyr::select()'/'dplyr::rename()'

View source: R/fselect.R

fselectR Documentation

Fast dplyr::select()/dplyr::rename()

Description

fselect() operates the exact same way as dplyr::select() and can be used naturally with tidy-select helpers. It uses collapse to perform the actual selecting of variables and is considerably faster than dplyr for selecting exact columns, and even more so when supplying the .cols argument.

Usage

fselect(data, ..., .cols = NULL)

frename(data, ..., .cols = NULL)

Arguments

data

A data frame.

...

Variables to select using tidy-select. See ?dplyr::select for more info.

.cols

(Optional) faster alternative to ... that accepts a named character vector or numeric vector.
No checks on duplicates column names are done when using .cols.
If speed is an expensive resource, it is recommended to use this.

Value

A data.frame of selected columns.

Examples

library(timeplyr)
library(dplyr)

df <- slice_head(iris, n = 5)
fselect(df, Species, SL = Sepal.Length)
fselect(df, .cols = c("Species", "Sepal.Length"))
fselect(df, all_of(c("Species", "Sepal.Length")))
fselect(df, 5, 1)
fselect(df, .cols = c(5, 1))
df %>%
  fselect(where(is.numeric))


timeplyr documentation built on Sept. 12, 2024, 7:37 a.m.