R Tip: Use vector(mode = "list") to Pre-Allocate Lists
Win-Vector Blog 2018-03-06
Summary:
Another R tip. Use vector(mode = "list") to pre-allocate lists. result <- vector(mode = "list", 3) print(result) #> [[1]] #> NULL #> #> [[2]] #> NULL #> #> [[3]] #> NULL The above used to be critical for writing performant R code (R seems to have greatly improved incremental list growth over the years). It … Continue reading R Tip: Use
vector(mode = "list")
to Pre-Allocate Lists