| which_min_iv {dvmisc} | R Documentation |
Return Index of (First) Minimum of an Integer Vector
Description
Written in C++, this function tends to run faster than
which.min for large integer vectors.
Usage
which_min_iv(x)
Arguments
x |
Integer vector. |
Details
For optimal speed, choose the version of this function that matches the
class of your x:
which_min_nv for numeric vector.
which_min_iv for integer vector.
which_min_nm for numeric matrix.
which_min_im for integer matrix.
Value
Integer value.
Examples
# For long vectors, which_min_iv is faster than which.min
x <- rpois(10000, lambda = 15)
which.min(x) == which_min_iv(x)
benchmark(which.min(x), which_min_iv(x), replications = 5000)
# For shorter vectors, which_min_iv is slower than which.min
x <- rpois(100, lambda = 15)
which.min(x) == which_min_iv(x)
benchmark(which.min(x), which_min_iv(x), replications = 20000)
[Package dvmisc version 1.1.4 Index]