modifies data.table in place, alias for modify
with copy=TRUE
and
sequential=TRUE
. It follows the naming convention in data.table
to
prefix methods that change objects (byreference) with set
.
setmodify(dat, x, ...)
dat |
|
---|---|
x |
|
... | not used |
Other modify:
modify,data.table,modifier-method
library(data.table) m <- modifier( if (age > 130) age = 130 , income[age < 12] <- 0 ) dat <- fread(text = "age, income 140, 300 11, 2000 25, 3000" ) # modify a copy of the data dat_m <- modify(dat, m, copy = TRUE) print(dat_m)#> age income #> 1: 130 300 #> 2: 11 0 #> 3: 25 3000#> age income #> 1: 130 300 #> 2: 11 0 #> 3: 25 3000