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:

• You cannot load any external packages, but any base R functions are allowed

To win

• You must email me your function brantly.callaway@uga.edu

• I’ll call the function on a vector of numbers. If it computes the correct maximum and minimum, then you 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