Reputation: 533
I'm looking for an alternative to this (which was provided as a solution here) that does not use funs()
since funs()
is soft deprecated as of dplyr 0.8.0:
mtcars %>% group_by(cyl) %>%
summarize_at(vars(disp, hp), funs(weighted.mean(.,wt)))
# cyl disp hp
# <dbl> <dbl> <dbl>
#1 4.00 110 83.4
#2 6.00 185 122
#3 8.00 362 209
Upvotes: 0
Views: 114
Reputation: 9247
As the R warning says, you have to use (in this case) a list of lambdas
mtcars %>% group_by(cyl) %>%
summarize_at(vars(disp, hp), list(~weighted.mean(., wt)))
Upvotes: 1