mean_i {dvmisc} | R Documentation |
Mean of Integer Values
Description
Written in C++, this function runs faster than mean
for
large integer vectors/matrices.
Usage
mean_i(x)
Arguments
x |
Integer vector or matrix. |
Value
Numeric value.
Examples
# For very large integer objects, sum_i is faster than sum
x <- rpois(100000, lambda = 5)
mean(x) == mean_i(x)
benchmark(mean(x), mean_i(x), replications = 1000)
# For smaller integer objects, sum_i is slower than sum
x <- rpois(1000, lambda = 5)
mean(x) == mean_i(x)
benchmark(mean(x), mean_i(x), replications = 1000)
[Package dvmisc version 1.1.4 Index]