How to expand a list with NULLs up to some length?
Given a list whose length <= N, what is the best / most efficient way to fill it up with trailing NULLs up to length (so that it has length N).
This is something which is a one-liner in any decent language, but I don't have a clue how to do it (efficiently) in a few lines in R so that it works for every corner case (zero length list etc.).
Let's keep it really simple:
tst<-1:10 #whatever, to get a vector of length 10 tst<-tst[1:15]
Try this :
> l = list("a",1:3) > N = 5 > l[N+1]=NULL > l []  "a" []  1 2 3 [] NULL [] NULL [] NULL >