If I say l = list()
and then I do l[[27]] = 100
, it will create 26 other entries with the 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 }
It will creat a list with entries ranging from 1 to 7, and NULL values for all the ones I did not assign. How can I avoid these spurious entries?