Hi, below is my static map page submission for the Week 2 project in JHU’s Data Products class. This webiste was generated using RStudio’s nice Rmd website tutorial.
This data is was sourced from the DC Metropolitan Police Department’s ASAP Crime database. The data set I am using here contains only the record of homicides in the District of Columbia for the year 2013, with information about the type of weapon used, time of day, city block.
I have used the ggmap::geocode() function to preprocess the data set and translate the dataset’s original city block information into lattitude and longitude coordinates for this visualization.
library(tidyverse)
library(leaflet)
library(RColorBrewer)
library(magrittr)
library(htmltools)
library(rgdal)
violent_crime <- readRDS("~/future/Capital_Crime/data/Violent_Crime_wLocs.RDS")
sub_crime <- filter(violent_crime, OFFENSE == "HOMICIDE")
sub_crime$METHOD %<>% as.factor()
offense_pal <- colorFactor("Dark2", domain = sub_crime$METHOD, alpha =1)
leaflet(sub_crime) %>% addProviderTiles("CartoDB.Positron") %>%
addCircleMarkers(color = ~offense_pal(METHOD),
weight = 2,
radius = 15,
opacity = .5,
fillOpacity = .25) %>%
addLegend("topright", pal = offense_pal, values = ~METHOD, title = "Murder Weapon")
The map points should be rendering in color depending on weapon used, but I’m not sure why this isn’y working on the gihub.io hosted version of the site. Local hosting works fine…if you have any input I’d appreciate it. Anyways, thanks for viewing!
Released under the GNU General Public License, version 3.