I was curious on how I can turn this to an Rcpp format? Because of memory problem, R's as.matrix method isn't working
sparse.cor4 <- function(x){
n <- nrow(x)
cMeans <- colMeans(x)
covmat <- (as.matrix(crossprod(x)) - n*tcrossprod(cMeans))/(n-1)
sdvec <- sqrt(diag(covmat))
cormat <- covmat/tcrossprod(sdvec)
list(cov=covmat,cor=cormat)
}
The function is from this link: Running cor() (or any variant) over a sparse matrix in R
Additional information: I was able to create a sparse matrix of 500kx500k using rcpp but I need to correlate that sparse matrix which wasn't possible with R's cor()
because of memory size which is why I am asking if I can convert the above function into Rcpp mode to get the correlation of the sparse matrix
Thanks