首页 > 解决方案 > R) 来自“Large vtcrs_list_of”的嵌套列表的汇总维度表

问题描述

我拥有的数据是大型嵌套数据集,我将 nrow() 应用于每个嵌套列表。

map(.x=df, .f=dim)

[[1]]
[1]  9 13

[[2]]
[1]  9 13

...(omit)

[[1999]]
[1]  1 13

[[2000]]
[1]  1 13

df %>% lapply(., nrow)
[[1]]
[1] 9

[[2]]
[1] 9
...

[[1999]]
[1] 1

[[2000]]
[1] 1

那么,如何创建一个表来汇总 Large vtcrs_list_of 中每个列表的行数?喜欢

nested nrow
list1    9
list2    9
...
list1999 1
list2000 1

标签: rnestedtibble

解决方案


这应该工作

listname <- paste("list", 1:2000, sep = "")
nrows <- df %>% sapply(., nrow) 
final_df <- data.frame(listname, nrows) 

推荐阅读