Description Usage Arguments Details Value Author(s) Examples
These two functions are fast C++ versions for column- and row-wise var
iance calculation on matrices/data.frames and are meant to substitute the classical apply(mat, 1, var)
approach.
1 2 |
x |
a matrix or data.frame |
They are coded in a way that they automatically remove NA
values, so they behave like na.rm = TRUE
.
A vector with the variance values.
Andrej-Nikolai Spiess
1 2 3 4 5 6 7 8 9 | ## Speed comparison on large matrix.
## ~ 110x speed increase!
## Not run:
MAT <- matrix(rnorm(10 * 500000), ncol = 10)
system.time(RES1 <- apply(MAT, 1, var))
system.time(RES2 <- rowVarsC(MAT))
all.equal(RES1, RES2)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.