Learn R Programming

BayesianFROC (version 1.0.0)

argMax: Arg Max: Extract a subscript corresponding component is a max

Description

The non-negative valued function of a vector, which returns a subscript whose component is the maximal component of the vector.

If the maximal component is not unique, then the lowest is chosen

Namely, for an arbitrary vector,

argMax(vector) = i

if and only if i is the smallest number such that

vector[i] >= vector[j] for all j.

Usage

argMax(numeric_vector, verbose = FALSE)

Arguments

numeric_vector

A vector, each component is a real number (an object of class numeric).

verbose

A logical, if TRUE, then verbose summary is printed in R or R studio console.

Value

A non-negative integer, indicating a subscript, corresponding component is the maximum component.

Details

This function is very fundamental and so,,, Is there a same function in the package base?

Examples

Run this code
# NOT RUN {
     argMax(c(0,0,0,0,0,0,0,0,0,0))
     argMax(c(11,0,0,0,0,0,0,0,0,0))
     argMax(c(0,22,0,0,0,0,0,0,0,0))
     argMax(c(0,0,33,0,0,0,0,0,0,0))
     argMax(c(0,0,0,44,0,0,0,0,0,0))
     argMax(c(0,0,0,0,55,0,0,0,0,0))
     argMax(c(0,0,0,0,0,66,0,0,0,0))
     argMax(c(0,0,0,0,0,0,77,0,0,0))
     argMax(c(0,0,0,0,0,0,0,88,0,0))
     argMax(c(0,0,0,0,0,0,0,0,99,0))

     # If the maximal component is not unique, then the lowest is chosen
     argMax(c(0,0,0,44,0,0,44,0,0,0))


     argMax(c(NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN))
     argMax(c(11,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN))
     argMax(c(NaN,22,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN))
     argMax(c(NaN,NaN,33,NaN,NaN,NaN,NaN,NaN,NaN,NaN))
     argMax(c(NaN,NaN,NaN,44,NaN,NaN,NaN,NaN,NaN,NaN))
     argMax(c(NaN,NaN,NaN,NaN,55,NaN,NaN,NaN,NaN,NaN))
     argMax(c(NaN,NaN,NaN,NaN,NaN,66,NaN,NaN,NaN,NaN))
     argMax(c(NaN,NaN,NaN,NaN,NaN,NaN,77,NaN,NaN,NaN))
     argMax(c(NaN,NaN,NaN,NaN,NaN,NaN,NaN,88,NaN,NaN))
     argMax(c(NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,99,NaN))
     argMax(c(NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,100))


     argMax(c(NaN,NaN,NaN,22,NaN,55,NaN,NaN,NaN,NaN))
     argMax(c(NaN,44,NaN,11,NaN,NaN,NaN,NaN,NaN,NaN))
     argMax(c(NaN,NaN,33, 33, 33, 33,NaN,NaN,NaN,NaN))

# }

Run the code above in your browser using DataLab