我有嵌套的tibble,在一个列表中,在一个列表中, struct 如下:
我基本上需要重新绑定所有内容中的数据帧.结果将是一个列表中的6个数据帧,每个季节(冬季/夏季)和物种组合一个.
> glimpse(list_graphs)
List of 2
$ winter:List of 3
..$ species1: tibble [161 x 1] (S3: tbl_df/tbl/data.frame)
..$ species2: tibble [38 x 1] (S3: tbl_df/tbl/data.frame)
..$ species3: tibble [72 x 1] (S3: tbl_df/tbl/data.frame)
$ summer:List of 3
..$ species1: tibble [33 x 1] (S3: tbl_df/tbl/data.frame)
..$ species2: tibble [2 x 1] (S3: tbl_df/tbl/data.frame)
..$ species3: tibble [52 x 1] (S3: tbl_df/tbl/data.frame)
我试过了:
map(list_graphs, function(x) {
map(x, function(x){
map(x,~do.call(rbind,x))
}
)
})
但是,这会导致以下不正确的结果:
List of 2
$ winter:List of 3
..$ species1:List of 1
.. ..$ graph_layer:List of 161
.. .. ..- attr(*, "dim")= int [1:2] 1 161
.. .. ..- attr(*, "dimnames")=List of 2
..$ species2:List of 1
.. ..$ graph_layer:List of 38
.. .. ..- attr(*, "dim")= int [1:2] 1 38
.. .. ..- attr(*, "dimnames")=List of 2
..$ species3:List of 1
.. ..$ graph_layer:List of 72
.. .. ..- attr(*, "dim")= int [1:2] 1 72
.. .. ..- attr(*, "dimnames")=List of 2
$ summer:List of 3
..$ species1:List of 1
.. ..$ graph_layer:List of 33
.. .. ..- attr(*, "dim")= int [1:2] 1 33
.. .. ..- attr(*, "dimnames")=List of 2
..$ species2:List of 1
.. ..$ graph_layer:List of 2
.. .. ..- attr(*, "dim")= int [1:2] 1 2
.. .. ..- attr(*, "dimnames")=List of 2
..$ species3:List of 1
.. ..$ graph_layer:List of 52
.. .. ..- attr(*, "dim")= int [1:2] 1 52
.. .. ..- attr(*, "dimnames")=List of 2
我肯定这是一个相对容易的解决办法,但我就是想不出来.我希望有人可以建议解决方案的基础上,我以上的 struct ,如果不是,我会try 和得到一个工作的正则表达式数据帧.
谢谢