Find Index of Maximum & Minimum Value of Vector & Data Frame in R (Example) | which.max & which.min

Published: 21 December 2019
on channel: Statistics Globe
10,793
56

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


Watch video Find Index of Maximum & Minimum Value of Vector & Data Frame in R (Example) | which.max & which.min online without registration, duration hours minute second in high quality. This video was added by user Statistics Globe 21 December 2019, don't forget to share it with your friends and acquaintances, it has been viewed on our site 10,793 once and liked it 56 people.