OneBite.Dev - Coding blog in a bite size

find the minimum and maximum element in an array in R

Code snippet on how to find the minimum and maximum element in an array in R

  my_array <- c(2, 3, 4, 5, 6, 7, 1)
  min_value <- min(my_array)
  max_value <- max(my_array)

This code first creates an array, called my_array, that contains the numbers 2 through 7. Then it uses the min() and max() functions to find the minimum and maximum value in the array, respectively. These values are assigned to the variables min_value and max_value. Finally, the code prints out the values of min_value and max_value, which are 1 and 7, respectively.

r