I have a dataset with two variables (x1 and x2) from many firms which belong to different industry groups. I calculate the variable "test1" for about 500 firms. We are given the follwing code:
df$test1 <- df$x1 - df$x2
library(broom)
result.test <- df %>%
group_by(industry) %>% do(tidy(t.test(.$test1, alt="two.sided", mu=0)))
The results are grouped by "industry" but it's not clear for me how the t test proceeds. Is the t-test performed for each variable "test1" and then the average result presented in industry group or is the average of "test1" determined for each industry group and then the t-test performed?