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
list
matrix
n
Something like this:
x <- vector('list', 10)
But using lapply is the best choice