What is the absolute fastest way to summarize by group in R? I've used data.table to optimize this step as much as I can but it's still the main bottleneck in my code as it has to run thousands of times.
library(data.table)
data <- matrix(rnorm(5e6 * 16), ncol = 16)
colnames(data) <- paste0("mark", 1:16)
group <- gl(10, 5e5, labels = paste0("sample", 1:10))
DT <- data.table(group, data) # 1/10 actual row #
out <- DT[, lapply(.SD, function(x) {mean(x^3)}), by = group]