preallocate list in R

前端 未结 3 947
渐次进展
渐次进展 2020-12-04 23:45

It is inefficient in R to expand a data structure in a loop. How do I preallocate a list of a certain size? matrix makes this easy via the n

3条回答
  •  心在旅途
    2020-12-05 00:21

    Something like this:

       x <- vector('list', 10)
    

    But using lapply is the best choice

提交回复
热议问题