idxMax: Get the position of a max element, resolving the ties in a...

Description Usage Arguments Value Examples

Description

If all elements are the same or if there is more than one max element, max element is chosen randomly. At the moment it cannot deal with NA's, an error will be issued.

Usage

1
idxMax(x, tol = 1e-16)

Arguments

x

A numeric vector.

tol

A scalar, small value, required to test the equality of real numbers.

Value

An integer denoting the position of a max element in vector x.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# create some numeric vectors
x <- rep(1, 10)
y <- 1:10
z <- c(0, rep(1, 10))

# get the index of max element
set.seed(1234)
idxMax(x)  # repeating will give different results
idxMax(y)
idxMax(z)  # repeating will give different results

hstojic/hfunk documentation built on May 17, 2019, 6:16 p.m.