Reputation: 1
I am having issues merging several data frames together. I have (plyr) uploaded and am attempting to use rbind to merge 6 data frames together. The output keeps telling me it is the wrong names. I do have each of the objects named as data.frames. Could that be the issue?
#Merging Species
Full.species <- rbind(Papio,Cebus,Gorilla,Human,Macaca,Pantrog,
use.names=TRUE)
Here is my output error message:
Error in match.names(clabs, names(xi)) :
names do not match previous names
Upvotes: 0
Views: 54
Reputation: 269644
There are several situations and it is not clear which of those is yours but:
1) rbind
will work if the data frames have the same names. Given your error message I assume that that is not your case.
2) If the data frames have the same number of columns and the first column of each corresponds and the second column of each corresponds, etc. then just change the column names on all the data frames but one to the names on that data frame.
names(DF3) <- names(DF2) <- names(DF)
rbind(DF, DF2, DF3)
3) If the different names should be put in different columns then use rbind.fill
from plyr:
library(plyr)
rbind.fill(DF, DF2, DF3)
Upvotes: 1