您可以使用do.call(Map, ...)
,这将嵌套列表作为参数传递给Map,它将以并行方式循环遍历这些列表并调用,rbind
因为该Map
函数将在同一位置绑定列表:
do.call(Map, c(f = rbind, nestedlist)) # [[1]] # ID valueA Category # 1 A1 0.1 Apples # 2 B2 0.2 Apples # 3 C3 0.3 Apples # 4 D4 0.4 Apples # 5 A1 0.1 Pears # 6 B2 0.2 Pears # 7 C3 0.3 Pears # 8 D4 0.4 Pears # 9 A1 0.1 Stairs # 10 B2 0.2 Stairs # 11 C3 0.3 Stairs # 12 D4 0.4 Stairs # # [[2]] # ID valueB Category # 1 A1 0.1 Apples # 2 B2 0.2 Apples # 3 C3 0.3 Apples # 4 D4 0.4 Apples # 5 A1 0.1 Pears # 6 B2 0.2 Pears # 7 C3 0.3 Pears # 8 D4 0.4 Pears # 9 A1 0.1 Stairs # 10 B2 0.2 Stairs # 11 C3 0.3 Stairs # 12 D4 0.4 Stairs