How can I assign a list in R without creating a lot of new elements?
If I say l = list()
and then I do l[[27]] = 100
, it will create 26 other records with value NULL
in them. Is there a way to avoid this?
For example, if I run: l <- list(); for (i in c(4,7,1)) { l[[i]] <- i^1 }
A list will be generated with entries 1 through 7 and NULL values ββfor all those that I have not assigned. How can I avoid these false entries?
+3
source to share