Is it possible somehow to do a t.test over multiple variables against the same categorical variable without going through a reshaping of the dataset as follows?
data(mtcars)
library(dplyr)
library(tidyr)
j <- mtcars %>% gather(var, val, disp:qsec)
t <- j %>% group_by(var) %>% do(te = t.test(val ~ vs, data = .))
t %>% summarise(p = te$p.value)
I´ve tried using
mtcars %>% summarise_each_(funs = (t.test(. ~ vs))$p.value, vars = disp:qsec)
but it throws an error.
Bonus: How can t %>% summarise(p = te$p.value)
also include the name of the grouping variable?