why is object.size is more for constant numeric vector?
Note this:
class(rep(1, 3))
[1] "numeric"
class(1:3)
[1] "integer"
On Tue, Jan 5, 2010 at 3:16 PM, Utkarsh Singhal <utkarsh.iit at gmail.com> wrote:
Hi All,
I ran the following lines in R:
print(object.size(a <- rep(1,10^6)),units="Mb")
print(object.size(a <- rep(3.542,10^6)),units="Mb")
print(object.size(b <- rep("x",10^6)),units="Mb")
print(object.size(b <- rep("xyzxyz xyz",10^6)),units="Mb")
print(object.size(b <- 1:10^6),units="Mb")
print(object.size(b <- rep(1:10,each=10^5)),units="Mb")
print(object.size(b <- rep(TRUE,10^6)),units="Mb")
The object size from first two lines is 7.6 MB, but from the last five it is
3.8 MB, although the length of vector is same.
Apparently, the size of any vector of a given length is twice if the vector
is numeric constant than if it is not.
Why is it so? Is my observation wrong? Or, is there some catch with
'object.size'?
Thanks in advance.
Regards
Utkarsh
? ? ? ?[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.