Column and row-wise variances and standard deviations | R Documentation |
Column and row-wise variances and standard deviations of a matrix
## S3 method for class 'matrix'
colVars(x, std = FALSE, na.rm = FALSE, parallel = FALSE, cores = 0)
## S3 method for class 'data.frame'
colVars(x, std = FALSE, na.rm = FALSE, parallel = FALSE, cores = 0)
colVars(x, std = FALSE, na.rm = FALSE, parallel = FALSE, cores = 0)
rowVars(x, std = FALSE, na.rm = FALSE, parallel = FALSE, cores = 0)
x |
A matrix with the data. |
std |
A boolean variable specyfying whether you want the variances (FALSE) or the standard deviations (TRUE) of each column. |
na.rm |
TRUE or FAlSE for remove NAs if exists. |
parallel |
Should parallel implentations take place in C++? The default value is FALSE. |
cores |
Number of cores to use for parallelism. Valid only when argument parallel is set to TRUE. Default value is 0 and it means the maximum supported cores. |
We found this on stackoverflow which was created by David Arenburg. We then modified the function to match the sums type formula of the variance, which is faster.
A vector with the column variances or standard deviations.
Michail Tsagris and Manos Papadakis.
R implementation and documentation: Michail Tsagris <mtsagris@uoc.gr> and Manos Papadakis <papadakm95@gmail.com>.
colmeans, colMedians, colrange
x <- matrix( rnorm(100 * 100), ncol = 100 )
a2 <- colVars(x)
x<-a2<-NULL
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.