Hello all, I was under the (false?) assumption that an object that is class logical, would take up less memory than an object with class integer. Below am I correctly showing this is not the case? This was an attempt to reduce memory usage. I'm dealing with two large arrays (could be integers). Their contents are the exact same, but one has NA's in random locations. I thought instead of having the second array as an integer, it could be logical and the TRUE vs FALSE could be used to update data in the first array. (but even this idea may be weak if I just end up with a third temporary array...) I'm running win xp sp3, "R version 2.14.1 (2011-12-22)". Thanks very much. Michael ______________________ arr<-array(1:60,c(3,4,5)) arr2<-array(TRUE,c(3,4,5)) mode(arr) class(arr) storage.mode(arr) mode(arr2) class(arr2) storage.mode(arr2) object.size(arr) object.size(arr2) ______________________________________ Michael Folkes Salmon Stock Assessment Canadian Dept. of Fisheries & Oceans Pacific Biological Station 3190 Hammond Bay Rd. Nanaimo, B.C., Canada V9T-6N7 Ph (250) 756-7264 Fax (250) 756-7053 Michael.Folkes@pac.dfo-mpo.gc.ca [[alternative HTML version deleted]]
On Mar 13, 2012, at 7:02 PM, Folkes, Michael wrote:> Hello all, > I was under the (false?) assumption that an object that is class > logical, would take up less memory than an object with class integer.Nope.> Below am I correctly showing this is not the case? > > This was an attempt to reduce memory usage.I think there is a package that will do bitwise operations. Yep... all we needed to do is look: http://finzi.psych.upenn.edu/R/library/bitops/html/00Index.html> I'm dealing with two large > arrays (could be integers). Their contents are the exact same, but > one > has NA's in random locations. I thought instead of having the second > array as an integer, it could be logical and the TRUE vs FALSE could > be > used to update data in the first array. (but even this idea may be > weak > if I just end up with a third temporary array...)You probably would since any assignment is going to create a copy. And even having a bitwise logical option wouldn't necessarily help since the indexing would be of necessity either integer or logical (both 8 bit values).> > I'm running win xp sp3, "R version 2.14.1 (2011-12-22)".31-bit addressing constraints as well? (That's so last decade.) You aren't making life easy for yourself are you.>-- David Winsemius, MD West Hartford, CT