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

Gregor Gorjanc gregor.gorjanc at bfro.uni-lj.si
Wed Sep 13 12:22:20 CEST 2006


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

-------- Original Message --------
Subject: Byte size in human readable format
Date: Mon, 21 Aug 2006 14:14:52 +0200
From: Gregor Gorjanc <gregor.gorjanc at bfro.uni-lj.si>
Reply-To: gregor.gorjanc at bfro.uni-lj.si
Organization: University of Ljubljana
To: r-devel at r-project.org
CC: Ales Korosec <korosale at email.si>

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.




More information about the R-devel mailing list