library(dplyr)
library(purrr)
mtcars %>% map_dbl(mean)
## mpg cyl disp hp drat wt
## 20.090625 6.187500 230.721875 146.687500 3.596563 3.217250
## qsec vs am gear carb
## 17.848750 0.437500 0.406250 3.687500 2.812500
mtcars %>% summarise_all(mean)
## mpg cyl disp hp drat wt qsec vs
## 1 20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875 0.4375
## am gear carb
## 1 0.40625 3.6875 2.8125
mtcars %>% summarise_each(funs(mean))
## mpg cyl disp hp drat wt qsec vs
## 1 20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875 0.4375
## am gear carb
## 1 0.40625 3.6875 2.8125
mtcars %>% summarise_at(1:11,funs(mean))
## mpg cyl disp hp drat wt qsec vs
## 1 20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875 0.4375
## am gear carb
## 1 0.40625 3.6875 2.8125
mtcars %>% summarise_at(vars('disp','cyl'),funs(mean))
## disp cyl
## 1 230.7219 6.1875
mtcars %>% summarise_at(vars(disp,am,cyl),funs(mean))
## disp am cyl
## 1 230.7219 0.40625 6.1875
mtcars %>% summarise_each(funs(mean),disp,cyl,am)
## disp cyl am
## 1 230.7219 6.1875 0.40625
mtcars %>% summarise_each_(funs(mean),vars(disp,cyl,am))
## disp cyl am
## 1 230.7219 6.1875 0.40625
mtcars %>% summarise_each(funs(mean),1:3)
## mpg cyl disp
## 1 20.09062 6.1875 230.7219
mtcars %>% summarise_each_(funs(mean),1:3)
## mpg cyl disp
## 1 20.09062 6.1875 230.7219
mtcars %>% summarise_each_(funs(mean),c('disp','cyl','am'))
## disp cyl am
## 1 230.7219 6.1875 0.40625