I need to get the mean of all columns of a large data set using R, grouped by 2 variables.
Lets try it with mtcars:
library(dplyr) g_mtcars <- gro
using data.table.(however you can't setDT(mtcars) because binding is locked. copy it to a different name like dt and try
setDT(mtcars)
library(data.table) mt_dt = as.data.table(mtcars) mt_dt[ , lapply(.SD, mean) , by=c("cyl", "gear")]