dt_starts_with: Select helpers

View source: R/select_helpers.R

dt_starts_withR Documentation

Select helpers

Description

These functions allow you to select variables based on their names.

  • dt_starts_with(): Starts with a prefix

  • dt_starts_with(): Ends with a suffix

  • dt_contains(): Contains a literal string

  • dt_everything(): Matches all variables

Usage

dt_starts_with(match)

dt_contains(match)

dt_ends_with(match)

dt_everything()

Arguments

match

a character string to match to variable names

Value

None. To be used within the ⁠dt_pivot_*⁠ functions.

Examples

library(data.table)

# example of using it with `dt_pivot_longer()`
df <- data.table(row = 1, var = c("x", "y"), a = 1:2, b = 3:4)
pv <- dt_pivot_wider(df,
  names_from = var,
  values_from = c(dt_starts_with("a"), dt_ends_with("b"))
)

tidyfast documentation built on May 29, 2024, 9:10 a.m.