unlisting a list while keeping the indices

后端 未结 2 874
渐次进展
渐次进展 2021-01-25 13:34

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(         


        
2条回答
  •  悲&欢浪女
    2021-01-25 14:11

    A "low level" solution:

    data.frame(entry=rep(seq_along(l1),lengths(l1)),element=unlist(l1))
    #  entry element
    #1     2      11
    #2     5      11
    #3     6      11
    #4     7       6
    #5     7      36
    #6     8      16
    #7     9      16
    

提交回复
热议问题