colVars: Column and row-wise variances and standard deviations of a...

Description Usage Arguments Details Value Author(s) Examples

Description

Column and row-wise variances and standard deviations of a matrix

Usage

1
2
colVars(x, suma = NULL, std = FALSE)
rowVars(x, suma = NULL, std = FALSE)

Arguments

x

A matrix with the data.

suma

If you already have the column sums vector supply it, otherwise leave it NULL.

std

A boolean variable specyfying whether you want the variances (FALSE) or the standard deviations (TRUE) of each column.

Details

We found this in stackoverflow and was created by David Arenburg. We then modified the function to match the sums type formula of the variance, which is faster.

Value

A vector with the colum variances or standard deviations.

Author(s)

Michail Tsagris

R implementation and documentation: Michail Tsagris <mtsagris@yahoo.gr> and Manos Papadakis <papadakm95@gmail.com>.

Examples

1
2
3
4
x <- matrix( rnorm(100 * 10000), ncol = 10000 )
system.time( a1 <- apply(x, 2, var) )
system.time( a2 <- colVars(x) )
all.equal(as.vector(a1), as.vector(a2))


Search within the Rfast package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.