5

I have a bunch of numbers to load into R for further anaysis. The numbers are small, <128. But there're 4G of such numbers. I would like to load them into a vector. Could I specify certain bits a integer taken in R to reduce memory usage? Breaking down the data was the only choice?

Gahoo
  • 215
  • 2
  • 9
  • your data is less than a byte? and you want to pack & store? – Nishanth Apr 14 '13 at 15:41
  • You could represent them as type `raw`, but then you'd lose all the numerical operations; there is only one integer size. Perhaps there are specialized packages for your data, e.g., [Bioconductor snpStats](http://bioconductor.org/packages/2.12/bioc/html/snpStats.html) for representation of SNPs. – Martin Morgan Apr 14 '13 at 15:57
  • 1
    Similar to @Martin's (I guess), I was going to suggest you compute the binary representations of your integers, then store the result using `as.bit` from the `bit` package. – flodel Apr 14 '13 at 16:15
  • Thanks @MartinMorgan's advice. It works fine. But it can not be compute directly? – Gahoo Apr 16 '13 at 06:42

1 Answers1

1

The ff CRAN package allows you to create vectors with 2,4,8,16 and 32 bit integers (signed or unsigned).

f3lix
  • 29,500
  • 10
  • 66
  • 86