[Rd] [Fwd: Byte size in human readable format]

From: Gregor Gorjanc <gregor.gorjanc_at_bfro.uni-lj.si>
Date: Wed 13 Sep 2006 - 10:22:20 GMT


Hello,

I have looked once more into this issue and used options() approach with (yet another :() option - humanReadable. This is the behaviour in R-devel.

> object.size(1000)

[1] 32
> c(object.size(1000), object.size(1:1000), object.size(1:1000000))
[1] 32 4024 4000024
> options(humanReadable=TRUE)
> object.size(1000)

[1] 32 B
> c(object.size(1000), object.size(1:1000), object.size(1:1000000))
[1] 32 B 4 kB 4 MB

I am not very satisfied with the class approach I have taken as a lot of functions in R drop class attribute, say

> sort(c(object.size(1:1000), object.size(1000)) )
[1] 32 4024

Is it possible to bypass this without writing special methods for "byte" class. I would appreciate any comments, suggestion. Thanks!

Patches are available at:

http://www.bfro.uni-lj.si/MR/ggorjan/tmp/object.size.R.patch
http://www.bfro.uni-lj.si/MR/ggorjan/tmp/object.size.Rd.patch
http://www.bfro.uni-lj.si/MR/ggorjan/tmp/NAMESPACE.patch
http://www.bfro.uni-lj.si/MR/ggorjan/tmp/humanReadable.Rd

Dear R-core,

My friend and I have written a function to convert byte size into human readable format as can be done with -h argument in say ls, df or du shell commands. I have also tried to wrap it with print method with object.size. Is there any intereset to include such a function into say utils package? Any additional comments, suggestions are more than welcome.

Function and its man page can be found at

http://www.bfro.uni-lj.si/MR/ggorjan/tmp/object.size.R http://www.bfro.uni-lj.si/MR/ggorjan/tmp/humanReadable.Rd

-- 
Lep pozdrav / With regards,
    Gregor Gorjanc

----------------------------------------------------------------------
University of Ljubljana     PhD student
Biotechnical Faculty
Zootechnical Department     URI: http://www.bfro.uni-lj.si/MR/ggorjan
Groblje 3                   mail: gregor.gorjanc <at> bfro.uni-lj.si

SI-1230 Domzale             tel: +386 (0)1 72 17 861
Slovenia, Europe            fax: +386 (0)1 72 17 888

----------------------------------------------------------------------
"One must learn by doing the thing; for though you think you know it,
 you have no certainty until you try." Sophocles ~ 450 B.C.

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Wed Sep 13 23:37:53 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 13 Sep 2006 - 16:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.