which_min: Where is is min or max value in a nmeric vector?

View source: R/which_min.R

which_minR Documentation

Where is is min or max value in a nmeric vector?

Description

Where is is min or max value in a nmeric vector?

Usage

which_min(x, return.method = "first")

which_max(x, return.method = "first")

Arguments

x

[numeric]
Numeric vector.

return.method

[string]
What to return in the presence of ties?

  • “first”: first occurence

  • “last”: last occurence

  • “random”: sampled uniformly at random from all positions

  • “all”: returns a vector of all positions

Default is “first”.

Value

Vector of integer position(s).

Examples

x = c(10, 24, 2, 2, 15, 2, 28)
lapply(c("first", "last", "random", "all"), function(m) {
 which_min(x, return.method = m)
})

jakobbossek/re documentation built on Nov. 15, 2024, 1:42 a.m.