which_min | R Documentation |
Works similar to base::which.min()
/base::which.max()
, but corrects for ties.
Missing values are treated as Inf
for which_min
and as -Inf
for which_max()
.
which_min(x, ties_method = "random", na_rm = FALSE)
which_max(x, ties_method = "random", na_rm = FALSE)
x |
( |
ties_method |
( |
na_rm |
( |
(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
.
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.