Sadegh
Sadegh

Reputation: 796

Predetermination of max memory allocation for a growing list file in loops (R)

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.

Upvotes: 0

Views: 72

Answers (1)

GWD
GWD

Reputation: 1464

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

Upvotes: 1

Related Questions