[r] rbind error: "names do not match previous names"

As part of a larger problem (adding a ,makeUniqueIDs argument to rbind.SpatialPolygonsDataFrame for situations when the polygon IDs are identical), I'm running into this weird message from rbind:

> do.call("rbind",xd.small)
Error in match.names(clabs, names(xi)) : 
  names do not match previous names

The only other info I could find on this was this question, which leads me to believe that rbind was at the root of the problem there also.

I can just write my own rbind-like function of course, but presumably this match.names check occurs for a reason, and I'm curious what it is.

This question is related to r

The answer is


easy enough to use the unname() function:

data.frame <- unname(data.frame)

check all the variables names in both of the combined files. Name of variables of both files to be combines should be exact same or else it will produce the above mentioned errors. I was facing the same problem as well, and after making all names same in both the file, rbind works accurately.

Thanks


rbind() needs the two object names to be the same. For example, the first object names: ID Age, the next object names: ID Gender,if you want to use rbind(), it will print out:

names do not match previous names


Use code as follows:

mylist <- lapply(pressure, function(i)read.xlsx(i,colNames = FALSE))#
mydata <- do.call('rbind',mylist)#