How can I make a list of lists in R?

后端 未结 5 700
逝去的感伤
逝去的感伤 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:50

    As other answers pointed out in a more complicated way already, you did already create a list of lists! It's just the odd output of R that confuses (everybody?). Try this:

    > str(list_all)
    List of 2
     $ :List of 2
      ..$ : num 1
      ..$ : num 2
     $ :List of 2
      ..$ : chr "a"
      ..$ : chr "b"
    

    And the most simple construction would be this:

    > str(list(list(1, 2), list("a", "b")))
    List of 2
     $ :List of 2
      ..$ : num 1
      ..$ : num 2
     $ :List of 2
      ..$ : chr "a"
      ..$ : chr "b"
    

提交回复
热议问题