which.min
Find the Index of the Minimum or Maximum Value

Description

Finds the index of the first minimum or maximum value in a vector of numeric or logical values.

Usage

which.min(x)
which.max(x)

Arguments

x A vector of non-complex numbers or logical values. Matrices and arrays are treated as vectors. If the input includes a complex number, the function discards the imaginary component and coerces it to a real number, and then returns the index value along with a warning message. In the case of logical values, TRUE is mapped to 1 and FALSE to 0. Missing values (NAs) are silently ignored.
Value
returns an integer specifying the index of the first occurance of the minimum (or maximum) value. If x contains only missing values (NAs), the return value is a zero-length integer vector (integer(0)).
See Also
which, min, order
Examples
which.max(c(1,NA,10,5))
# [1] 3
which.min(c(12, 3, 1+5i, 2, TRUE, 9))  
# Warning: imaginary parts discarded in coercion
which.max(c(NA, NA, NA)) # integer(0)
Package base version 6.0.0-69
Package Index