which_min(x, ties_method = "random", na_rm = FALSE)
which_max(x, ties_method = "random", na_rm = FALSE)

## 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. |

na_rm |
(`logical(1)` )
Remove NAs before computation? |

## Value

(`integer()`

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

is `TRUE`

).
Returns `NA`

if `na_rm`

is `FALSE`

and at least one `NA`

is found in `x`

.

## Examples

#> [1] 3

which_min(x, ties_method = "last")

#> [1] 7

which_min(x, ties_method = "random")

#> [1] 3

which_max(x)

#> [1] 5

#> integer(0)

which_max(NA)

#> [1] NA

#> [1] NA