For this code challenge, you need to write a function that takes in a vector of numbers, computes the maximum and the minimum value in the vector of numbers, and returns both of them in a list.

Rules:

To win



Solution below…















max_min <- function(x) {
  the_max <- max(x)
  the_min <- min(x)
  list(max=the_max, min=the_min)
}

max_min(mtcars$mpg)
## $max
## [1] 33.9
## 
## $min
## [1] 10.4