Hi community stackoverflow!
Can someone kindly help me, as I am having some difficulty creating a choropleth map in R. At the moment, I have assigned LL information to my interests, and now I want to create a choropleth map using "cans" in the data set (data .csv) by high school district (highdist_n83.shp.zip). I would like you to know how to correctly fill in the card with the amount of cans in the district square. I have provided code that extracts an example data file from dropbox and a form file that I would like to use.
EDIT Sorry, I forgot to add that when I draw only the form file, I can see how it is displayed through ggplot. However, when I try to βfillβ the areas using the number of βcansβ variables, R hangs for a while before displaying what appears to be a mass of lines above the original shape. I wonder if an error occurs due to the following possible reasons.
- The form file is not good.
- There may be a problem with the way I combine the data frame and the form file, as I noticed that the added lines are added to the combined file
- There are several schools in the area that I have not combined when using ddply.
Thank you for your time!
setup data frames dl_from_dropbox("data.csv","dx3qrcexmi9kagx") data<-read.csv(file='data.csv',header=TRUE) choropleth map: mapPlot <- ggplot(newdata,aes(x=long, y=lat,drop=FALSE)) + geom_polygon(aes(fill=cans, drop=FALSE), colour = "black", lwd = 1/9,na.rm=FALSE) + ggtitle("Total of Cans Across State") print(mapPlot)
source share