I downloaded a polygon shape file (england_ct_1991.shp) from a zip file I downloaded here and csv file (england_ct_1991.csv) from a zip file here that I want to connect together. I added a new column to the csv file called 'price' so each county has a unique price like this:
name,label,x,y,priceAvon,9,360567.1834,171823.554,11Avon,9,322865.922,160665.4829,11Bedfordshire,10,506219.5005,242767.306,20Berkshire,11,464403.02,172809.5331,23....
I joined the shp and csv by the county name. The problem is the map is not superimposing on the price to show a nice color gradient on the counties based on the price. I checked some youtube tutorials stating the important part is joining but it worked for them so I am unsure what I did wrong? Thanks in advance for any advice.
library(ggplot2)library(sf)library(tidyverse)# map of england countiesmap7 <- read_sf("england_ct_1991.shp")head(map7)ggplot(map7) +geom_sf()# get x (longitude) y (latitude) county names and pricestotalPrices <- read_csv("england_ct_1991.csv")head(totalPrices)# join map and csv data on county namemappedData <- left_join(map7, totalCounts, by="name")head(mappedData)# print mapmap1 <- ggplot(mappedData, aes( x=x, y=y, group=name)) + geom_polygon(aes(fill=price), color="black") + geom_sf()map1