Using the following data
df <- data.frame(category = sample(1:3, replace = TRUE, 50),
testgroup = sample(c('A', 'B'), replace = TRUE, 50),
var_1 = rnorm(50),
var_2 = rnorm(50),
var_3 = rnorm(50)
)
I would like to apply a 2-sample-t-test in each category comparing the difference in means between A and B with respect to all 3 variables.
Ideally, the output is generated using the tidyverse and broom packages.
I was struggling too long with the split-apply-combine-approach and I guess there is already a nice solution out there with a few lines of code.
Thanks a lot for your support!