我有一个列表,如:
list(list(goals = c(42L, 52L, 55L),
season = "88",
player = c("a", "b","c")),
list(goals = c(41L,53L, 37L, 40L),
season = "89",
player = c("a","b", "c", "d")))
Run Code Online (Sandbox Code Playgroud)
我想将其转换为长格式的数据帧,如:
goals player season
42 a 88
52 b 88
.
.
41 a 89
53 b 89
.
Run Code Online (Sandbox Code Playgroud)
我可以用以下方式实现这一点plyr:
plyr::ldply(mylist, data.frame, .id="season"
我想可能有更新的方式使用purrr或dplyr?