I am making a map by tmap in R by combining the data using the area code. Not all the crime data is available. After I combining the data of the area and the crime data, I cannot plot the map
uk_la1 <- readOGR(dsn = "./infuse_dist_lyr_2011", layer = "infuse_dist_lyr_2011")
Totalcrime <- read.csv('Total_crime_in_each_area_full.csv', header = TRUE)
# Calculate the nnumber of crime per 1000 people
Totalcrime <- transform(Totalcrime, Crime_per_1000_people = Total / Population * 1000)
Totalcrimeno<-Totalcrime %>% select(geo_code, Crime_per_1000_people)
uk_la1@data<-left_join(uk_la1@data, Totalcrimeno,
by=c('geo_code'))
qtm(uk_la, fill="Crime_per_1000_people")
But I get an error:
Error in
$<-.data.frame
(*tmp*
, "geometry", value = list(list(list( : replacement has 404 rows, data has 405