How can I make a list of lists in R?

后端 未结 5 673
逝去的感伤
逝去的感伤 2020-12-24 00:58

I don\'t know how to make a list of lists in R. I have several lists, I want to store them in one data structure to make accessing them easier. However, it looks like you ca

5条回答
  •  借酒劲吻你
    2020-12-24 01:30

    If you are trying to keep a list of lists (similar to python's list.append()) then this might work:

    a <- list(1,2,3)
    b <- list(4,5,6)
    c <- append(list(a), list(b))
    
    > c
    [[1]]
    [[1]][[1]]
    [1] 1
    
    [[1]][[2]]
    [1] 2
    
    [[1]][[3]]
    [1] 3
    
    
    [[2]]
    [[2]][[1]]
    [1] 4
    
    [[2]][[2]]
    [1] 5
    
    [[2]][[3]]
    [1] 6
    

提交回复
热议问题