rbind error: “names do not match previous names”

前端 未结 5 460
旧时难觅i
旧时难觅i 2020-12-01 07:16

As part of a larger problem (adding a ,makeUniqueIDs argument to rbind.SpatialPolygonsDataFrame for situations when the polygon IDs are identical),

5条回答
  •  余生分开走
    2020-12-01 07:44

    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.

提交回复
热议问题