For some reason when I try to use paste as part of a group_by_ only one of the two elements in the vector that the paste creates gets used as a group_by_ for the summarising on the next line. Is there any way to keep both the "gear_CI" and the "carb_CI" columns? (I realize the purpose of why I'm trying to group_by might not make a lot of sense in this context, but this is just meant to be a reproducible example)
somecols <- c("gear", "carb")
mtcars %>%
mutate_at(vars(somecols), funs(CI = qnorm(.975) * .)) %>%
group_by_("wt", paste0(somecols, "_CI")) %>%
summarise_at(vars(somecols), mean)
# A tibble: 31 x 4
# Groups: wt [29]
# wt gear_CI gear carb
# <dbl> <dbl> <dbl> <dbl>
# 1 1.51 9.80 5 2
# 2 1.62 7.84 4 2
# 3 1.84 7.84 4 1
# 4 1.94 7.84 4 1