How to find the index of the maximum and minimum value with the which.max and which.min functions of the R programming language. More info: https://statisticsglobe.com/r-find-in...
R code:
vec <- c(3, 1, 8, 3, 2, 5) # Create example vector
which.max(vec) # Identify index of max value
which.min(vec) # Identify index of min value
data <- data.frame(x1 = c(7, 8, 1, 4, 0, 5), # Create example data frame
x2 = letters[1:6])
data # Print data to RStudio console
which.max(data$x1) # Apply which.max function to column
which.min(data$x1) # Apply which.min function to column