This help topic is for R version 1.1. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/base/html/which.min.html
which.min {base}R Documentation

Where is the Min() or Max() ?

Description

Determines the location, i.e., index of the (first) minimum or maximum of a numeric vector.

Usage

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

Arguments

x

numeric vector, whose min or max is searched.

Value

an integer of length 1, giving the index of the first minimum or maximum respectively of x.

If this extremum is unique, the result is the same (but more efficient) as which(x == min(x)) or which(x == max(x)) respectively.

Author(s)

Martin Maechler

See Also

which, max.col, max, etc.

Examples

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

[Package base version 1.1 ]