I have been using merge() to merge my geojson file with csv data in R. My codes are as follows:
map@data <- merge(map@data, csvdata, by.x="ID", by.y="ID")
However, after exporting the geojson file and rendering it, the wrong numbers are always allocated to the wrong polygons.
Since the polygons were rendered properly, I guessed that there must be an error in the merge. I then tried to merge the csv data with the .shp version of the map layer on QGIS, before exporting it as geojson. This did not create any problems, which led me to the conclusion that the merging of the csv data and the map is the problem.
Is merge() incompatible with geojson file types? If so, what function from which package can I use instead?