Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

getMaxIndex

Return index of maximal/minimal/best element in numerical vector.


Description

If x is empty or only contains NAs which are to be removed, -1 is returned.

Usage

getMaxIndex(x, ties.method = "random", na.rm = FALSE)

getMinIndex(x, ties.method = "random", na.rm = FALSE)

getBestIndex(x, minimize = TRUE, ...)

Arguments

x

[numeric]
Input vector.

ties.method

[character(1)]
How should ties be handled? Possible are: “random”, “first”, “last”. Default is “random”.

na.rm

[logical(1)]
If FALSE, NA is returned if an NA is encountered in x. If TRUE, NAs are disregarded. Default is FALSE

minimize

[logical(1)]
Minimal element is considered best? Default is TRUE.

...

[any]
Further arguments passed down to the delegate.

Value

[integer(1)].

Note

Function getBestIndex is a simple wrapper for getMinIndex or getMaxIndex respectively depending on the argument minimize.


BBmisc

Miscellaneous Helper Functions for B. Bischl

v1.11
BSD_2_clause + file LICENSE
Authors
Bernd Bischl [aut, cre], Michel Lang [aut], Jakob Bossek [aut], Daniel Horn [aut], Jakob Richter [aut], Dirk Surmann [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.