Description Usage Arguments Value Examples
Returns index of minimum for vectors and index or (row, column) position for
matrices. For optimal speed, use integer = TRUE
if x
is an
integer vector/matrix and integer = FALSE
otherwise. Typically faster
than which.min
for matrices and for large vectors.
1 | which.min2(x, arr.ind = FALSE, integer = FALSE)
|
x |
Integer or numeric vector/matrix. |
arr.ind |
Logical value for whether to return (row, col) position rather
than vector position, if |
integer |
Logical value for whether |
Numeric value.
1 2 3 4 5 6 7 8 9 | # which.min2 vs. which.min for integer vector
x <- rpois(10000, lambda = 10)
all.equal(which.min(x), which.min2(x, integer = TRUE))
benchmark(which.min(x), which.min2(x, integer = TRUE), replications = 10000)
# which.min2 vs. which.min for numeric vector
x <- rnorm(10000)
all.equal(which.min(x), which.min2(x))
benchmark(which.min(x), which.min2(x), replications = 10000)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.