The RgoogleMaps package offers tremendous ease of use but does not allow you control over the map elements and the type of layout. So we will look at another R package, ggmap, powered by the popular ggplot2 package, to overlay data points over the map. In this section, we will analyze the Chicago crime dataset downloaded from https://data.cityofchicago.org/ and simplified for this example:
- Install and load ggmap and maps and read the data, chicago-crime.csv:
> install.packages(c("ggmap","maps"))> library(maps)> library(ggmap)> crimes <- read.csv("chicago-crime.csv")
- Format the Date column into Date object:
> crimes$Date = strptime(crimes$Date, format = "%m/%d/%y %H:%M")
- Get the map of Chicago using the get_map function ...