Another way to address the issue is by using a dplyr/tidyr approach. If you haven't installed dplyr or tidier you can do that by typing the following into your console.
install.packages("dplyr")
install.packages("tidyr")
The piece of code which calculates the min and max.
library(dplyr)
library(tidyr)
min_max <- function(df, funs, ...) {
dots <- quos(...)
df %>%
select(...) %>%
summarise_if(is.numeric, funs) %>%
gather("Var", "Value") %>%
separate(Var, sep = "_", into = c("value", "stat"))
}
min_max(iris, funs(min, max), Sepal.Length, Sepal.Width, Petal.Length, Petal.Width)