Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
考虑以下具有不同长度的向量元素列表:
test = list(c(A = 1, B = 2), c(A = 3, C = 1), c(A = 9), c(A = 6, B = 7, C = 8))
我想将列表转换为数据框,同时以下列方式匹配元素的名称:
# A B C # 1 2 NA # 3 NA 1 # 9 NA NA # 6 7 8
library(plyr) rbind.fill(lapply(test, function(x) as.data.frame(t(x)))) # A B C #1 1 2 NA #2 3 NA 1 #3 9 NA NA #4 6 7 8