0
mylist <- list(structure(c(1L, 1L, 2L, 2L, 2L, 2L, NA, NA), .Names = c("A",
"B", "C", "D", "E", "F", "G", "H")), structure(c(1L, 1L, 1L,
1L, 1L, 2L, 1L, NA), .Names = c("A", "B", "C", "D", "E", "F",
"G", "H")))
mylist
[[1]]
A B C D E F G H
1 1 2 2 2 2 NA NA
[[2]]
A B C D E F G H
1 1 1 1 1 2 1 NA
我有一個像上面的列表,我想將它摺疊成一個data.frame,這樣我可以集中每一個單獨列即df$A
,df$B
等談到列表爲data.frame
> df$A
[1] 1 1
> df$B
[1] 1 1
> df$C
[1] 2 1
如此反覆
我想你想'do.call(rbind,lapply(mylist,as.data.frame.list))' –
@RichardScriven謝謝。這正是我想要的 – Adrian
其實,有了這個,因爲你已經有了所有的數值,你可以使用'as.data.frame(do.call(rbind,mylist))' –