Bug 16321 - Vectorize utils::object.size and friends
Summary: Vectorize utils::object.size and friends
Status: NEW
Alias: None
Product: R
Classification: Unclassified
Component: Wishlist (show other bugs)
Version: R 3.2.0
Hardware: All All
: P5 enhancement
Assignee: R-core
Depends on:
Reported: 2015-04-17 20:17 UTC by Greg Warnes
Modified: 2015-04-17 20:25 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Greg Warnes 2015-04-17 20:17:51 UTC
utils::object_size accepts only a single item as an argument, and the 'object_size' methods only support a scalar argument, making it inconvenient to get and manipulate object sizes for multiple objects.

For instance, getting the sizes of all objects in the current namespace requires:

sizes <- sapply( ls(), utils:object.sizes)

which loses the formatting provided by utils:::print.object_size via utils:::format.object_size.

To get around this, we've provided gdata::object_size and friends, which are essentially vectorized wrappers or work-alikes for utils::object size, etc.  


> a <- rnorm(1e3); b <- rnorm(1e4)
> gdata::object.size( a, b )
[1] 8 kB  80 kB

Extending utils::object.size to support multiple arguments and vectorizing utils:::format.object_size and utils::print.object_size would obviate the need for these functions in gdata.
Comment 1 Greg Warnes 2015-04-17 20:25:53 UTC
In addition, it may be a good idea to switch to the IEC standard units:

       Name        System  Symbol  Size        Conversion      
       byte        binary    B     2^3         8 bits          
       kilobyte   decimal    kB    10^3        1000 bytes      
       kibibyte    binary   KiB    2^{10}      1024 bytes      
       megabyte   decimal    MB    (10^3)^2    1000 kilobytes  
       mebibyte    binary   MiB    (2^{10})^2  1024 kibibytes  
       gigabyte   decimal    GB    (10^3)^3    1000 megabytes  
       gibibyte    binary   GiB    (2^{10})^3  1024 mebibytes  
       terabyte   decimal    TB    (10^3)^4    1000 gigabytes  
       tebibyte    binary   TiB    (2^{10})^4  1024 gibibytes  
       petabyte   decimal    PB    (10^3)^5    1000 terabytes  
       pebibyte    binary   PiB    (2^{10})^5  1024 tebibytes  
       exabyte    decimal    EB    (10^3)^6    1000 petabytes  
       exbibyte    binary   EiB    (2^{10})^6  1024 pebibytes  
       zettabyte  decimal    ZB    (10^3)^7    1000 exabytes   
       zebibyte    binary   ZiB    (2^{10})^7  1024 exbibytes  
       yottabyte  decimal    YB    (10^3)^8    1000 zettabytes 
       yebibyte    binary   YiB    (2^{10})^8  1024 zebibytes  
where Zi and Yi are GNU extensions to IEC.

     Wikipedia: <URL: http://en.wikipedia.org/wiki/Byte> <URL:
     http://en.wikipedia.org/wiki/SI_prefix> <URL:

     GNU manual for coreutils: <URL: