r max and min functions

# Create a numeric vector
numbers <- c(5, 2, 8, 1, 7)

# Find the maximum value in the vector
max_value <- max(numbers)
print(paste("Maximum value:", max_value))

# Find the index of the maximum value in the vector
max_index <- which.max(numbers)
print(paste("Index of maximum value:", max_index))

# Find the minimum value in the vector
min_value <- min(numbers)
print(paste("Minimum value:", min_value))

# Find the index of the minimum value in the vector
min_index <- which.min(numbers)
print(paste("Index of minimum value:", min_index))