Learn R Programming

tidytable (version 0.8.0)

select.: 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

Run this code
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)

Run the code above in your browser using DataLab