select: Select or drop columns

View source: R/select.R

selectR Documentation

Select or drop columns

Description

Select or drop columns from a data.table

Usage

select(.df, ...)

Arguments

.df

A data.frame or data.table

...

Columns to select or drop. Use named arguments, e.g. new_name = old_name, to rename selected variables. tidyselect compatible.

Examples

df <- data.table(
  x1 = 1:3,
  x2 = 1:3,
  y = c("a", "b", "c"),
  z = c("a", "b", "c")
)

df %>%
  select(x1, y)

df %>%
  select(x1:y)

df %>%
  select(-y, -z)

df %>%
  select(starts_with("x"), z)

df %>%
  select(where(is.character), x1)

df %>%
  select(new = x1, y)

tidytable documentation built on Sept. 11, 2024, 8:05 p.m.