Skip to content

why is object.size is more for constant numeric vector?

3 messages · Utkarsh Singhal, Gabor Grothendieck, Brian Ripley

#
Note this:
[1] "numeric"
[1] "integer"
On Tue, Jan 5, 2010 at 3:16 PM, Utkarsh Singhal <utkarsh.iit at gmail.com> wrote:
#
On Wed, 6 Jan 2010, Utkarsh Singhal wrote:

            
Your observation is faulty.  The first two are type "double", and a C 
double takes 8 bytes.  The last three are type "integer" or "logical" 
with values stored in C int, 4 bytes each.  Character strings are 
harder to compute storage for as identical strings share storage.  On 
a 32-bit machine identical strings take an extra 4 bytes per string, 
on a 64-bit machine an extra 8 bytes.  If you look at the values in 
bytes you will see that 'twice' is an approximation.

So

- the storage needed depends on the type of the vector as well as the 
length.

- for character vectors it depends on the architecture and the 
content.

Please do consult the R manuals rather than expect others to read them 
for you: this is all in the 'R Internals' manual.