Creating (and Accessing) a Sparse Matrix with NA default entries

前端 未结 2 1912
长发绾君心
长发绾君心 2020-12-01 08:40

After learning about the options for working with sparse matrices in R, I want to use the Matrix package to create a sparse matrix from the following data frame and have all

2条回答
  •  再見小時候
    2020-12-01 09:17

    Why do you want default NA values? As far as I know matrices are only sparse if they have zero-cells. As NA is a non-zero value, you loose all the benefits from the sparse matrix. A classic matrix is even more efficient if the matrix has hardly any zeros. A classic matrix is like a vector that will be cut according to the dimensions. So it only has to store the data vector and the dimensions. The sparse matrix stores only the non-zero values, but also stores there location. This is an advantage if and only if you have enough zero values.

提交回复
热议问题