I have a list which can have either empty entries, entries containing one elements and entries containing multiple elements.
l1 = list(integer(0), 11L, integer(
We can have two options. Make the list a named one, enframe it to a tbl_df and then unnest the list element. The NULL elements will be automatically removed
library(tidyverse)
l1 %>%
set_names(seq_along(.)) %>%
enframe %>%
unnest
Or after naming the list, stack it to a 2 column data.frame
stack(setNames(l1, seq_along(l1)))[2:1]