I have a vector of lists and I use unlist on them. Some of the elements in the vectors are NULL and unlist seems to be dropping them.<
unlist
NULL
In this case (one level depth list) this should works too:
a[sapply(a, is.null)] <- NA unlist(a) # p1 p2 p1 p2 p1 p2 p1 p2 # 2 5 3 4 NA NA 4 5