statar (version 0.4.0)

keep: Create new data.table by keeping only certain columns (equivalent to dplyr::select)

Description

Create new data.table by keeping only certain columns (equivalent to dplyr::select)

Usage

keep(x, ...)

keep_(x, vars)

Arguments

x
a data.table
...
Variables to keep. Default to all. See the select documentation.
vars
Used to work around non-standard evaluation.

Examples

Run this code
library(data.table)
DT <- data.table(
  id = c(1,2),
  v1 = c(1,1),
  v2 = c(2,1)
)
keep(DT, id, v2)
keep(DT, -id)

Run the code above in your browser using DataLab