0

When you have a x<-list() file in a loop, as function progress, its size increases and therefore memory allocation also increases. After a while you may encounter with memory error. How is it possible to guess max needed memory and also dedicate it from the beginning?

Can making a pre-defined size make sense? Or is there a better method for this?

Regards.

Sadegh
  • 788
  • 5
  • 15
  • 1
    I do not think lists, if used properly, suffer the limitations you are suggesting. See http://stackoverflow.com/q/12772522/1201032 – flodel Apr 29 '14 at 10:33

1 Answers1

1

Something like this

 x <- vector('list', 10) 

since vector can create empty vector of the desired mode and length.

Answer taken from earlier SO question

Community
  • 1
  • 1
GWD
  • 1,387
  • 10
  • 22