I am using summarise_at() to obtain the mean and standard error of multiple variables by group.
每个组的输出有 1 行,每个组的每个计算量有 1 列。我想要一个表格,每个变量有 1 行,每个计算量有 1 列:
data <- mtcars
data$condition <- as.factor(c(rep("control", 16), rep("treat", 16)))
data %>%
group_by(condition) %>%
summarise_at(vars(mpg, cyl, wt),
funs(mean = mean, se=sd(.)/sqrt(n())))
# A tibble: 2 x 7
condition mpg_mean cyl_mean wt_mean mpg_se cyl_se wt_se
<fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 control 18.2 6.5 3.56 1.04 0.387 0.204
2 treat 22.0 5.88 2.87 1.77 0.499 …Run Code Online (Sandbox Code Playgroud)