def_cols: Create and assign new columns in data.table

View source: R/def_cols.R

def_colsR Documentation

Create and assign new columns in data.table

Description

function used to create new columns in data.table using non-standard evaluation

Usage

def_cols(dt, ...)

Arguments

dt

a data.table

...

formula using ~ notation where LHS is the new column name and RHS is an expression for the values More than one new columns can be created by having formulas separated by commas

Value

returns a data.table

Examples

## Not run: 
dt <- data.table(mtcars)
define(dt, kmpl ~ mpg / 2.35215, wt_in_kg ~ wt / 2.20462)
# creating two columns / converted units
define(dt, am = NULL) # remove a column

## End(Not run)

kleu046/wr.data.table documentation built on April 25, 2022, 1:41 p.m.