range_n: "Range" (Actually Minimum and Maximum) of Numeric Values

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/functions.R

Description

Written in C++, this function should always run faster than range for numeric vectors/matrices. For integer objects, range_i should run even faster.

Usage

1

Arguments

x

Numeric vector or matrix.

Details

NA

Value

Numeric vector.

Note

NA

Author(s)

Dane R. Van Domelen

References

Acknowledgment: This material is based upon work supported by the National Science Foundation Graduate Research Fellowship under Grant No. DGE-0940903.

See Also

NA

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# In general, range_n is much faster than range.
x <- rnorm(1000)
all.equal(range(x), range_n(x))
microbenchmark(range(x),
               range_n(x),
               times = 100)
               
# For integer vectors, range_i should be even faster.
x <- rpois(1000, lambda = 5)
all.equal(range(x), range_i(x))
microbenchmark(range(x),
               range_n(x),
               range_i(x),
               times = 100)

dvmisc documentation built on Dec. 29, 2017, 3:01 a.m.