rajeshj at cse.iitm.ac.in
2010-Sep-06 06:54 UTC
[R] max limit of list size and vector size?
Hi, Is it possible for me to store a list of vectors of 1 million entries? like, cc<-list(c(1,2,........1million),c(1,2,........1million)....) also what is the length of the longest string in R? I keep getting info from a socket and keep pasting on a string...when will this start becoming a problem? [[alternative HTML version deleted]]
It is easy to store a list of that size:> x <- list(1:1e6, 1:1e6, 1:1e6) > object.size(x)12000112 bytes> str(x)List of 3 $ : int [1:1000000] 1 2 3 4 5 6 7 8 9 10 ... $ : int [1:1000000] 1 2 3 4 5 6 7 8 9 10 ... $ : int [1:1000000] 1 2 3 4 5 6 7 8 9 10 ... Now it really depends on how you are processing the data. If you are appending to a vector each time: myData <- c(myData, newData) This is not efficient since it may be making copies of the vector each time to extend it. It is best to preallocate the vector and then store the result: myData <- numeric(1000000) # hold 1 million values for (i in 1:1e6) myData[i] <- newData My rule of thumb is that a single object should take up no more than 25% of the available RAM so that copies can be made during the processing. HTH On Mon, Sep 6, 2010 at 2:54 AM, rajeshj at cse.iitm.ac.in <rajeshj at cse.iitm.ac.in> wrote:> > Hi, > > Is it possible for me to store a list of vectors of 1 million entries? > like, > cc<-list(c(1,2,........1million),c(1,2,........1million)....) > > also > > what is the length of the longest string in R? I keep getting info from a socket and keep pasting on a string...when will this start becoming a problem? > ? ? ? ?[[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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?