Calculate the variance for each row of a matrix or data frame.
rowVars(x, ...)A numeric vector containing the variance for each row
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)