| rowVars | R Documentation |
Calculate the variance for each row of a matrix or data frame.
rowVars(x, ...)
x |
A numeric matrix or data frame |
... |
Additional arguments passed to rowSums and rowMeans |
This function computes the sample variance for each row using the formula: var = sum((x - mean(x))^2) / (n - 1) # Calculate row variances for a matrix # mat <- matrix(1:12, nrow = 3) # row_vars <- rowVars(mat)
A numeric vector containing the variance for each row
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.