SVD for sparse matrix in R

后端 未结 4 2119
情歌与酒
情歌与酒 2020-12-06 02:16

I\'ve got a sparse Matrix in R that\'s apparently too big for me to run as.matrix() on (though it\'s not super-huge either). The as.matrix()

4条回答
  •  春和景丽
    2020-12-06 02:40

    So here's what I ended up doing. It's relatively straightforward to write a routine that dumps a sparse matrix (class dgCMatrix) to a text file in SVDLIBC's "sparse text" format, then call the svd executable, and read the three resultant text files back into R.

    The catch is that it's pretty inefficient - it takes me about 10 seconds to read & write the files, but the actual SVD calculation takes only about 0.2 seconds or so. Still, this is of course way better than not being able to perform the calculation at all, so I'm happy. =)

提交回复
热议问题