rfloating-pointcompressionprecisionsingle-precision

Writing floating point numbers in single precision to file in R?


I understand that R doesn't have a floating point format in single precision. However, I'm writing a very large number of data points from R to file, and I'd like to store them as single precision floats, rather than double precision. I don't need good accuracy on these numbers.

Any way I can do that? I want to save as much space as possible, and even compression or dumping as binary isn't enough.

Edit: Is there a way to write .rds files as single precision floats?

Thanks!


Solution

  • Using signif(data, X) before write.RDS seems to work. Thanks all.