which.min {base} | R Documentation |
Determines the location, i.e., index of the (first) minimum or maximum of a numeric vector.
which.min(x)
which.max(x)
x |
numeric vector, whose |
an integer
of length 1 or 0 (iff x
has no
non-NA
s) , giving the index of the first minimum or
maximum respectively of x
.
If this extremum is unique (or empty), the result is the same (but more
efficient) as which(x == min(x))
or which(x == max(x))
respectively.
Martin Maechler
which
, max.col
, max
, etc.
x <- c(1:4,0:5,11)
which.min(x)
which.max(x)
data(presidents)
presidents[1:30]
range(presidents, na.rm = TRUE)
which.min(presidents)# 28
which.max(presidents)# 2