sparse.cor | R Documentation |
Computes a sparse correlation matrix from a given sparse matrix input. This function is useful for efficiently handling large datasets where most values are zero, facilitating the calculation of both covariance and correlation matrices without converting to a dense format.
sparse.cor(smat)
smat |
A sparse matrix object, typically of class Matrix from the Matrix package. |
A list with two elements:
cov
: The covariance matrix derived from the input sparse matrix.
cor
: The correlation matrix derived from the covariance matrix.
## Not run:
library(Matrix)
smat <- Matrix(rnorm(1000), nrow = 100, sparse = TRUE)
cor_res <- sparse.cor(smat)
print(cor_res$cor)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.