Reduce the size of a large matrix filled with only a few kinds of elements in R

I have a matrix sdist

in the R

following way.

library("babynames")
library("stringdist")
d <- babynames
sdist <- stringdistmatrix(d$name[1:1000], d$name[1001:10000], method="lv", useBytes = T)
sdist[sdist > 3] <- Inf

      

The size of this matrix is โ€‹โ€‹large, even if there are only a few element types.

object.size(sdist)
72000112 bytes

dim(sdist)
[1] 1000 9000
length(sdist)
[1] 9000000

table(sdist)
sdist
      0       1       2       3     Inf 
   4093   12125   72937  381084 8529761 

      

Is there a way to reduce the size of these types of matrices. I cannot use sparse matrices since the number 0s is less.

+3
memory matrix r


source to share


No one has answered this question yet

Check out similar questions:

22
Matrix library for .NET
6
Slow performance of matrix multiplication using MTJ / Netlib (native)
3
R Large difference in matrix size
2
Linear Algebra Algorithm (MATLAB and C)
2
Filling a large matrix and calculations
1
How to avoid allocating large matrices
0
Filling a large matrix with an equation in R
0
Creating a sparse matrix using awk
0
"bigmemory" to highlight a large matrix
0
Algorithms for executing large integer matrix operations w / Numerical stability



All Articles
Loading...
X
Show
Funny
Dev
Pics