which.max()
function in R Language is used to return the location of the first maximum value in the Numeric Vector.
Syntax: which.max(x)
Parameters:
x: Numeric Vector
Example 1:
x < - c( 2 , 3 , 4 , 5 , 1 , 2 , 3 , 1 , 2 )
which. max (x)
x[which. max (x)]
|
Output:
[1] 4
[1] 5
Example 2:
BOD$demand
which. max (BOD$demand)
BOD$demand[which. max (BOD$demand)]
|
Output:
[1] 8.3 10.3 19.0 16.0 15.6 19.8
[1] 6
[1] 19.8