Select A Column That Maximizes A Function in R
select_maximum <- function(data, evaluation = stats::median, ...) {
index_max_eval <- data %>%
summarise_all(evaluation, ..., .groups = "drop") %>%
magrittr::extract(1, ) %>%
as.numeric() %>%
which.max()
data %>%
magrittr::extract(index_max_eval)
}