My questions are related to this:
Rotate vector output into columns in data.table?
But my situation is a little more complicated. I not only return the vector as columns, but also compute other columns at the same time. For instance:.
DT = data.table(X = 1:10, Y = 11:20, Z = 21:30, group = rep(1:10, each = 3)) featuresDT <- quote(list(x = mean(X), y = mean(Y), z = mean(Z), as.list(quantile(X)))) DT[, eval(featuresDT), by = "group"]
where quantile returns a vector of length 5. Instead of getting a data table with 8 columns, I get one of 4 columns, and the quantile results quantile displayed as additional rows, and x, y and z duplicated 5 times. I also tried dist = as.list(quantile(X) , but this gives the same result but a different column name.
source share