0

I want to make multiple plots (in r) of the occurrence of crime in a certain city. The city has 42 zip codes, and I want to make a plot for each of the zip codes (i.e. 42 plots in total). My data recorded seven different types of crime, and I want to identify each type of crime with a different color. So for each plot (representing a zip code) I would have different colors for different crime. I want to plot the data on a satellite map from google earth. I wrote this code to do it:

Zip <- Sepfel$Zipcode
for(i in unique(Sepfel$Zipcode)){   
map <- get_map(location='Lezmmas', zoom=11, maptype="satellite")
ggmap(map) + geom_point(subset(Sepfel,Sepfel$Zipcode==i), aes(color=Offense, x=Longitude, y=Latitude),size=0.00001, alpha=1) + ggtitle(paste("September 2015")) 
} 

But the code doesn't run. Could someone help me to fix this?

aosmith
  • 34,856
  • 9
  • 84
  • 118
Stone
  • 7
  • 2
  • 1
    Welcome to Stack Overflow! Your question does not contain a [reproducible example](http://stackoverflow.com/q/5963269/4303162). It is therefore hard to understand your problem and give you an appropriate answer. Please make your data available (e.g. by using `dput()`) or use one of the example data sets in R. Also, add the minimal code required to reproduce your problem to your post. – Stibu Apr 22 '16 at 13:47
  • Do you get an error message, or just nothing happens. Remember you have to `print` ggplot objects. – Richard Telford Apr 22 '16 at 13:55
  • It runs but you don't see anything? Then wrap the `ggmap` stuff in a `print` function. – lmo Apr 22 '16 at 14:19
  • You might also think to change all Sepfel$Zipcode by Zip, which is easier and you already made this object. And to be sure to have the same colors for the same crime, information is here:http://stackoverflow.com/questions/19068432/ggplot2-how-to-use-same-colors-in-different-plots-for-same-factor – Wave Apr 22 '16 at 14:21

0 Answers0