I\'m using dplyr\'s summarise_each to apply a function to multiple columns of data. One thing that\'s nice is that you can apply multiple functions at once. Thing is, it\'
You can achieve a similar output combining the dplyr
and tidyr
packages.
Something along these lines can help
library(dplyr)
library(tidyr)
iris %>%
select(matches("Petal")) %>%
summarise_each(funs(min, max)) %>%
gather(variable, value) %>%
separate(variable, c("var", "stat"), sep = "\\_") %>%
spread(var, value)
## stat Petal.Length Petal.Width
## 1 max 6.9 2.5
## 2 min 1.0 0.1