which_min

0th

Percentile

Index of the Minimum/Maximum Value, with ties correction

Works similar to base::which.min()/base::which.max(), but corrects for ties. Missing values are set to Inf for which_min and to -Inf for which_max().

Usage
which_min(x, ties_method = "random")

which_max(x, ties_method = "random")

Arguments
x

:: numeric() Numeric vector.

ties_method

:: character(1) Handling of ties. One of "first", "last" or "random" (default) to return the first index, the last index, or a random index of the minimum/maximum values. Passed down to base::max.col().

Value

(integer()): Index of the minimum/maximum value. Returns an empty integer vector for empty input vectors and vectors with no non-missing values.

Aliases
  • which_min
  • which_max
Examples
# NOT RUN {
x = c(2, 3, 1, 3, 5, 1, 1)
which_min(x, ties_method = "first")
which_min(x, ties_method = "last")
which_min(x, ties_method = "random")

which_max(x)
which_max(integer(0))
which_max(NA)
which_max(c(NA, 1))
# }
Documentation reproduced from package mlr3misc, version 0.1.0, License: LGPL-3

Community examples

Looks like there are no examples yet.