rowVars {metaMA} | R Documentation |
Row variance of an array
Description
Calculates variances of each row of an array
Usage
rowVars(x, na.rm = TRUE)
Arguments
x |
Array of two or more dimensions, containing numeric, complex, integer or logical values, or a numeric data frame. |
na.rm |
Logical. Should missing values (including NaN) be omitted from the calculations? |
Details
This function is the same as applying apply with FUN=var but is a lot faster.
Value
A numeric or complex array of suitable size, or a vector if the result is one-dimensional. The dimnames (or names for a vector result) are taken from the original array.
Examples
## The function is currently defined as
function (x,na.rm = TRUE)
{
sqr = function(x) x * x
n = rowSums(!is.na(x))
n[n <= 1] = NA
return(rowSums(sqr(x - rowMeans(x,na.rm = na.rm)), na.rm = na.rm)/(n - 1))
}
[Package metaMA version 3.1.3 Index]