I want to create a map of China that demonstrates the value of the ethnic heterogeneity index. I want to generate the map as in this webpage, https://mgimond.github.io/Spatial/mapping-data-in-r.html
I gathered the .shp file of provinces from Hijmans, Robert J., University of California, Berkeley. Museum of Vertebrate Zoology. Second-level Administrative Divisions, China, 2015 [map]. No Scale Provided. Retrieved April 15, 2021, from https://geodata.lib.utexas.edu/catalog/stanford-nt024fn0432
But I do not know how to append "ethnic heterogeneity index" to this file? The ethnic heterogeneity index is stored as a CSV. file and the common variable for both files is "province". My current csv file does not contain the longitude and latitude information for provinces, is that the problem?
chinaprovincedf <- as(chinaprovince, "data.frame")
Error in as(chinaprovince, "data.frame") :
internal problem in as(): “sf” is(object, "data.frame") is TRUE, but the metadata asserts that the 'is' relation is FALSE
I am not sure how to proceed.
sf
you just need to merge withmerge(shapefile, mycsv)
as usual, assuming that they share a common variable. The result is asf
with the data frommycsv