rbind 多个数据集 [英] rbind multiple data sets
问题描述
我有 3 个数据集要绑定在一起.我已将我的列重命名为相同的:
names(DF1) <- c("A", "B", "C")名称(DF2)<- c(A",B",C")名称(DF3)<- c(A",B",C")
他们每个人都有不同数量的观察(分别为 34、54、23)
但是,当我尝试使用 rbind 函数时,它返回错误:
total <- rbind(DF1, DF2, DF3)
<块引用>
match.names(clas, names(xi)) 中的错误:名称与以前的名称不匹配
从其他已回答的问题来看,错误应该是由于不同命名的列而出现的,但我已经检查并重新检查它们的重命名是否相同.
我想最终得到一个总数据集,其中包含 111 个带有列标题的观察值.我是 R 的初学者,其他问题的许多答案都让我望而却步.有没有人能够用外行的话来回答这个问题?
你可以使用 do.call
,像这样:
do.call("rbind", list(DF1, DF2, DF3))
注意 do.call
的第二个参数是一个列表.
I have 3 data sets that I want to rbind together. I have renamed my columns to be the same:
names(DF1) <- c("A", "B", "C")
names(DF2) <- c("A", "B", "C")
names(DF3) <- c("A", "B", "C")
They have each got different numbers of observations (34, 54, 23, respectively)
However, when I try with an rbind function, it returns the error:
total <- rbind(DF1, DF2, DF3)
Error in match.names(clabs, names(xi)) : names do not match previous names
From other answered questions the error should arise because of differently named columns, but I have checked and rechecked that they have been renamed the same.
I would like to end up with a total dataset with a total of 111 observations with column titles. I am a beginner to R, so many of the answers from other questions elude me. Would anyone be able to answer this in layman terms?
You can use do.call
, like so:
do.call("rbind", list(DF1, DF2, DF3))
Note that second argument of do.call
is a list.
这篇关于rbind 多个数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!