which_min_nv: Return Index of (First) Minimum of a Numeric Vector

Description Usage Arguments Details Value Examples

View source: R/RcppExports.R

Description

Written in C++, this function tends to run faster than which.min for large numeric vectors.

Usage

1

Arguments

x

Numeric 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

1
2
3
4
5
6
7
8
9
# For long vectors, which_min_nv is faster than which.min
x <- rnorm(100000)
which.min(x) == which_min_nv(x)
benchmark(which.min(x), which_min_nv(x), replications = 1000)

# For shorter vectors, which_min_nv is slower than which.min
x <- rnorm(100)
which.min(x) == which_min_nv(x)
benchmark(which.min(x), which_min_nv(x), replications = 10000)

vandomed/dvmisc documentation built on Oct. 2, 2020, 9:50 p.m.