Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert a sparse matrix to a full matrix - R

Tags:

r

I am looking for an efficient way to convert a huge sparse matrix to a full matrix (not to a dataframe) in R?

Any idea?

Thanks.

like image 584
Ester Silva Avatar asked Jun 11 '16 13:06

Ester Silva


1 Answers

We can use as.matrix

m1 <- as.matrix(sM)

where sM is the sparse matrix.

We can check the methods

grep("as.matrix", methods(class = "sparseMatrix"), value = TRUE)
#[1] "as.matrix,Matrix-method"
like image 145
akrun Avatar answered Oct 01 '22 06:10

akrun