Hello all, im quite new to all this Rstudio. but im trying to make a choropleth map of Denmark. ive got the map to show and work from a .rds file from gadm.org. but when i have to fill each polygon with other data (csv), i fall short and have no idea how to continue.
library(sp) DK <- readRDS("dk2.rds") library(tibble) library(dplyr) library(ggplot2) ##here the map is showing and everything is fine ggplot(data = DK, aes(x=long, y=lat, group=group)) + geom_polygon(fill="white", color="blue") + coord_map() ##now trying to add the csv file DKtal <- read.csv("DKtal2.csv") ##merging the two files final_map <- merge(DK, DKtal, by = "NAME_2") ##plotting the new map with the fill set at "tal" which should assign a value to some of the regions in denmark. but nothing happens ggplot(data = final_map, aes(x=long, y=lat, group=group)) + geom_polygon(color="white", fill=tal) + coord_map() ##all it gives me is this message ##Regions defined for each Polygons ##Error in layer(data = data, mapping = mapping, stat = stat, geom = GeomPolygon, : ## object 'tal' not found
So all in all I'm having problems with merging the two datasets correct i think.
any body who has an idea on what to do here?