Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Histogram of large matrix in R

I have a large, square sparse matrix in R (about 30M real numbers), and I'd like to see the distribution of its values. If I use the hist function, as most values are 0, I get a very tall first bar and then a very long tail very close to 0, something like: I______

So I guess I should print only nonzero values, or rescale the values in order to show the pattern of non zero values in a meaninful way. Is there a way to tell hist to filter out certain values? I'd like to include only values in (0,1).

like image 611
Mulone Avatar asked Dec 12 '25 06:12

Mulone


1 Answers

A matrix is just a vector that's been told about it's column and row assignments... it'll turn back into one if you just treat it like one. .....

hist( myMatrix[myMatrix > 0 & myMatrix < 1] )
like image 95
John Avatar answered Dec 15 '25 21:12

John



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!