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, \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.
Details

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

Note that transform will keep the key of the data.table provided the ``targets'' of the transform (i.e. the columns that appear in ...) are not in the key of the data.table. within also retains the key provided the key columns are not ``touched''.

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.7.1, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.