R + combine a list of vectors into a single vector

后端 未结 6 775
死守一世寂寞
死守一世寂寞 2021-01-30 10:37

I have a single list of numeric vector and I want to combine them into one vector. But I am unable to do that. This list can have one element common across the list element. Fin

6条回答
  •  北恋
    北恋 (楼主)
    2021-01-30 11:05

    You want rle:

    rle(unlist(lst))$values
    
    > lst <- list(`1`=1:2, `2`=c(2,4,5), `3`=c(5,9,1))
    > rle(unlist(lst))$values
    ## 11 21 22 31 32 33 
    ##  1  2  4  5  9  1 
    

提交回复
热议问题