transform.data.table

0th

Percentile

Data table utilities

Utilities for data.table transformation.

Keywords
data
Usage
## S3 method for class 'data.table':
transform(`_data`, \ldots)
## S3 method for class 'data.table':
within(data, expr, keep.key = FALSE, \ldots)
Arguments
data, _data
data.table to be transformed.
...
for transform, Further arguments of the form tag=value. Ignored for within.
expr
expression to be evaluated within the data.table.
keep.key
logical; if TRUE, keep the sorted key.
Details

within is like with, but modifications (columns changed, added, or removed) are updated in the returned data.table.

Note that transform always removes the key, and within has an option to keep it.

Value

  • The modified value of data.

See Also

transform and within

Aliases
  • transform.data.table
  • within.data.table
Examples
dt <- data.table(a=rep(1:5, 1), b=1:10)

transform(dt, c = a^2)

within(dt, {
  b <- rev(b)
  c <- a^2
  rm(a)
})

# dt[, transform, c = max(b), by="a"]  # like "ave"
Documentation reproduced from package data.table, version 1.4.1, License: GPL

Community examples

Looks like there are no examples yet.