【发布时间】:2021-09-22 10:55:09
【问题描述】:
我知道这是一个新手问题,我有这 3 个 xlsx 文件,其中包含 3 个相同 14 个变量的三个数据库,它是一个横截面数据面板, 我想要的只是将它们连接到一个名为 eplt 的数据库中, 首先,我导入它们
library(dplyr)
library(ggplot2)
library(xlsx)
##Import the three data bases
epl_data<-read.xlsx("Notes_ETAB2016-2017.xlsx",sheetIndex = 1,header = TRUE)
epl_data2<-read.xlsx("Notes_ETAB2017-2018.xlsx",sheetIndex = 1,header = TRUE)
epl_data3<-read.xlsx("Notes_ETAB2018-2019.xlsx",sheetIndex = 1,header = TRUE)
## to render the number of rows in each of them
nrow(epl_data)
nrow(epl_data2)
nrow(epl_data3)
# I want to rbind the three sets together
eplt<-rbind(epl_data,epl_data2,epl_data3)
总行数是 29441,但是当应用 Rbind 将它们绑定在一起时,我得到了错误
> eplt<-rbind(epl_data,epl_data2,epl_data3)
Error in match.names(clabs, names(xi)) :
names do not match previous names
但是3组变量的名字是一样的 有人可以帮忙吗,我只想重新绑定 25000 个观察值,剩下的 4441 个将其与多元回归模型的可预测 obs 进行比较, 提前致谢
【问题讨论】:
-
能否提供所有三个数据框的变量名称?
-
好的,我会编辑帖子,谢谢
-
另外,我鼓励您在从 Excel 导入数据时使用
janitor::clean_names(data)。通过使变量名标准化,它可以很好地处理导入excel文件时的变量名问题 -
需要什么
dplyr和ggplot2函数? -
@user2161721
epl_data3 <- epl_data3 %>% rename(SVT = Svt)
标签: r merge concatenation rbind cbind