I am having some trouble trying to plot a density map for crime in my city. I'm using the two-dimensional kernel density estimation through the stat_density2d()
function. No matter what I change and/or rearrange, I am continually receiving the error message
Discrete value supplied to continuous scale
I ran the str
function to check the structure; Lon(gitude) was being read as a character.
OakTownMap +
stat_density2d(aes(x = lon, y = lat, fill = ..level.. ,alpha=..level..), bins = 10, geom ="polygon", data = Non_Violent_Crime) +
scale_fill_gradient(low = "black", high = "red")+
ggtitle("Map of Non-Violent Crime Density in Oakland ")
I'm truly lost and a little frustrated because I'm sure this requires a very simple adjustment to placement of lon and lat arguments or change in function(?). Should I just change lon from char to num?