I'd like to use data.table to do some wrangling and would like my resulting data table to not include the grouping variable.
Here's a MWE:
library("data.table")
DT <- data.table(x = 1:10, grp = rep(1:2,5))
DT[, .(mmm = mean(x)), by = grp]
This produces:
grp mmm
1: 1 5
2: 2 6
which is all fine. However, I'd prefer the grp not to be here. This can be fixed by chaining the data.table calls and setting grp := NULL or just throwing the variable away, but can I prevent it in the first call so I only return mmm?