使用rbind()组合不同的数据集

时间:2013-11-23 20:03:29

标签: r statistics

我现在正在做一个项目,面临将多个数据集合并到一个数据集中的问题。但是,当我尝试将这些项与rbind函数组合时,我只能组合前两个数据集。当合并三个以上时,会有一条消息说

  

match.names(clabs,names(xi))出错:   名称与以前的名称不匹配

这是我的代码:

```{r, message=FALSE}
require(mosaic); require(Sleuth2); require(MASS); require(leaps)
options(digits=3)
trellis.par.set(theme=col.mosaic())  # get a better color scheme for lattice
BelgiumMa <-read.csv("BelgiumMa.csv")
BrazilCh<- read.csv("BrazilCh.csv")
BosSerb <- read.csv("BosSerb.csv")
NetherSpain <- read.csv("NetherSpain.csv")
TunisiaSouth <- read.csv("TunisiaSouth.csv")
BangMala <- read.csv("BangMala.csv")
HonBraz <- read.csv("HonBraz.csv")
MalaChin <- read.csv("MalaChin.csv")
DenSwit <- read.csv("DenSwit.csv")
CamNic <- read.csv("CamNic.csv")
total <- rbind(BelgiumMa, BrazilCh, BosSerb, NetherSpain, TunisiaSouth, BangMala,
HonBraz, MalaChin, DenSwit, CamNic)
```

1 个答案:

答案 0 :(得分:1)

library(plyr)
rbind.fill(BelgiumMa, BrazilCh, BosSerb, NetherSpain, TunisiaSouth, BangMala,
HonBraz, MalaChin, DenSwit, CamNic)