As part of a larger problem (adding a ,makeUniqueIDs
argument to rbind.SpatialPolygonsDataFrame
for situations when the polygon IDs are identical),
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
The names of the first dataframe do not match the names of the second one. Just as the error message says.
> identical(names(xd.small[[1]]), names(xd.small[[2]]) )
[1] FALSE
If you do not care about the names of the 3rd or 4th columns of the second df, you can coerce them to be the same:
> names(xd.small[[1]]) <- names(xd.small[[2]])
> identical(names(xd.small[[1]]), names(xd.small[[2]]) )
[1] TRUE
Then things should proceed happily.
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
easy enough to use the unname()
function:
data.frame <- unname(data.frame)
Use code as follows:
mylist <- lapply(pressure, function(i)read.xlsx(i,colNames = FALSE))#
mydata <- do.call('rbind',mylist)#