View source: R/general_tools.R
| get_rowVar | R Documentation |
Efficiently computes the variance of each row for either a base R dense matrix or a sparse dgCMatrix, via a single Rcpp entry point. Logs progress messages to the R console.
get_rowVar(M, verbose = FALSE)
M |
A numeric matrix (base R matrix) or a sparse matrix of class |
verbose |
Logical. If |
Dispatches in C++ between dense and sparse implementations to avoid unnecessary overhead or external dependencies. Uses compressed-column traversal for sparse inputs.
A numeric vector of length nrow(M) containing the variance of each row.
Only 32-bit integer indices are supported, due to limitations in R's internal matrix representations. This function will not work with matrices that exceed the 32-bit integer indexing range.
library(Matrix)
# Dense example
dm <- matrix(rnorm(1000), nrow = 100)
get_rowVar(dm)
# Sparse example
sm <- rsparsematrix(100, 10, density = 0.1)
get_rowVar(sm)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.