A<-c("a","b","c","d")
B<-c("a","b","c","d")
C<-list(c("a","b","c","d"),c("a","b","c","d"))
D<-c("a","b","c","d")
x<-list(A,B,C,D)
如何将列表x转换为数据帧而不使用&#34; for&#34; ?
答案 0 :(得分:1)
数据框需要具有相同长度的列。你的C列只有两个元素,因为它由两个列表组成,每个列表中有四个项目,我假设C是一个2列4行数据帧。为最终数据框中更好的列名命名列表元素。
A<-c("a","b","c","d")
B<-c("a","b","c","d")
C<-list(C1 = c("a","b","c","d"), C2= c("a","b","c","d"))
D<-c("a","b","c","d")
df <- data.frame(A, B, C, D)