R convert matrix or data frame to sparseMatrix

前端 未结 3 1881
日久生厌
日久生厌 2020-12-23 20:46

I have a regular matrix (non-sparse) that I would like to convert to a sparseMatrix (using the Matrix package). Is there a function to do this or

3条回答
  •  猫巷女王i
    2020-12-23 21:20

    For the matrix, someone already has an answer.

    For the data.table, there is a package did the job.

    library(Matrix)
    library(mltools)
    x = data.table()
    sparseM <- sparsify(x) 
    

提交回复
热议问题