Remove empty elements from list with character(0)

后端 未结 5 1867
渐次进展
渐次进展 2020-12-13 08:33

How can I remove empty elements from a list that contain zero length pairlist as character(0), integer(0) etc...

list2
# $`hsa:7476         


        
5条回答
  •  天命终不由人
    2020-12-13 09:07

    Another option(I think more efficient) by keeping index where element length > 0 :

    l[lapply(l,length)>0] ## you can use sapply,rapply
    
    [[1]]
    [1] 1 2 3
    
    [[2]]
    [1] "foo"
    

提交回复
热议问题