powered by
## S3 method for class 'data.table': transform(`_data`, \ldots) ## S3 method for class 'data.table': within(data, expr, keep.key = FALSE, \ldots)
transform
tag=value
within
TRUE
data
with
Note that transform always removes the key, and within has an option to keep it.
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"
Run the code above in your browser using DataLab