HenrikBengtsson / R.utils

🔧 R package: R.utils (this is *not* the utils package that comes with R itself)
https://henrikbengtsson.github.io/R.utils/
62 stars 14 forks source link

Add hsize() for human readable object sizes #43

Closed HenrikBengtsson closed 8 years ago

HenrikBengtsson commented 8 years ago

Example of hsize() usages:

hsize(1024)
1.0 KiB

hsize(1024^3)
1.0 GiB

hsize(1024^3, units="bytes")
1073741824 bytes

hsize(1024^3, units="SI")
1.1 GB

hsize(1024^3, digits=3, units="SI")
1.074 GB

hsize(8192, digits=2, units="SI")
8.92 kB

The default should be units=getOption("hsize", "IEC"). If R ever gets its own option for this and/or choose a different default, we can easily depend on that here too.

See also https://github.com/HenrikBengtsson/Wishlist-for-R/issues/6