for an object, data.tableI would like to collapse the values of some grouped columns into a single object and insert the resulting objects into a new colum.
dt <- data.table(
c('A|A', 'B|A', 'A|A', 'B|A', 'A|B'),
c(0, 0, 1, 1, 0),
c(22.7, 1.2, 0.3, 0.4, 0.0)
)
setnames(dt, names(dt), c('GROUPING', 'NAME', 'VALUE'))
dt
I think that for this you must first specify the column for which you want to group, so I should start with something like dt[, OBJECTS := <expr>, by = GROUPING].
Unfortunately, I do not know the expression <expr>to use, so the result is as follows:
Each <vector>must contain the values of the other columns. For example, the first <vector>should be a named vector equivalent to:
eg <- c(22.7, 0.3)
names(eg) <- c('0', '1')