| col_vars | R Documentation |
Compute the sample variance for each column of a numeric matrix.
col_vars(obj, cores = 1)
obj |
A numeric matrix. |
cores |
Integer. Number of cores to use for parallel computation.
Defaults to |
Columns with fewer than two non-missing values are assigned NA.
NA/NaN are treated as missing and dropped (equivalent to
var(x, na.rm = TRUE)). Inf/-Inf are not missing. They enter the
arithmetic, so a column's variance can be NaN, matching base R.
A numeric vector of column variances, named if obj has column
names.
set.seed(123)
obj <- matrix(rnorm(7 * 10), ncol = 7)
obj[1, 1] <- Inf
obj[1, 2] <- NA
obj[1:8, 3] <- NA
obj[8, 3] <- Inf
obj[1:8, 4] <- NA
obj[1:8, 5] <- NA
obj[9, 5] <- obj[10, 5]
obj[1:9, 6] <- NA
obj[, 7] <- NA
obj
col_vars(obj)
apply(obj, 2, var, na.rm = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.