Mass shootings in the US have been recorded and provided as free data to the public. This project uses data from mass shootings that occurred from 1982 to 2015.
The original dataset provided by the Data.World is accessible as an excel file. This file is available to any individual for free on their website: https://data.world/awram/us-mass-shootings/workspace/file?filename=USMassShootings.xlsx
library(readxl)
dat<- read_excel("USMassShootings.xlsx")
Here is the structure of the dataset:
str(dat)
## tibble [71 × 25] (S3: tbl_df/tbl/data.frame)
## $ CASE : chr [1:71] "Chattanooga military recruitment center" "Charleston Church Shooting" "Marysville-Pilchuck High School shooting" "Alturas tribal shooting" ...
## $ GENDER : chr [1:71] "Male" "Male" "Male" "Female" ...
## $ SHOOTINGTYPE : chr [1:71] "Mass" "Mass" "Mass" "Mass" ...
## $ RACE : chr [1:71] "Middle Eastern" "White" "Native American" "Native American" ...
## $ LOCATION : chr [1:71] "Chattanooga, Tennessee" "Charleston, South Carolina" "Marysville, Washington" "Alturas, California" ...
## $ STATE : chr [1:71] "Tennessee" "South Carolina" "Washington" "California" ...
## $ DATE : chr [1:71] "7/16/2015" "6/17/2015" "10/24/2014" "2/20/2014" ...
## $ YEAR : num [1:71] 2015 2015 2014 2014 2013 ...
## $ SUMMARY : chr [1:71] "Kuwaiti-born Mohammod Youssuf Abdulazeez, 24, a naturalized US citizen, opened fire at a Naval reserve center, "| __truncated__ "Dylann Storm Roof, 21, shot and killed 9 people after opening fire at the Emanuel AME Church in Charleston, Sou"| __truncated__ "Jaylen Fryberg, 15, using a .40-caliber Berretta, shot five \r\nstudents at Marysville High School, including t"| __truncated__ "Cherie Lash Rhoades, 44, opened fire at the Cedarville Rancheria Tribal Office and Community Center, killing fo"| __truncated__ ...
## $ FATALITIES : num [1:71] 5 9 5 4 12 7 6 5 5 28 ...
## $ WOUNDED : num [1:71] 2 1 1 2 8 0 3 0 2 2 ...
## $ TOTALVICTIMS : num [1:71] 7 10 6 6 20 7 9 5 7 30 ...
## $ LOCATIONTYPE : chr [1:71] "Military" "Religious" "School" "Other" ...
## $ PRIORSIGNSOFMENTALILLNESS: chr [1:71] "Yes" "No" "No" "No" ...
## $ MENTALHEALTHNOTES : chr [1:71] "Abdulazeez \"had suffered for years from depression and possibly from bipolar disorder,\" according to a repres"| __truncated__ NA "Fryberg was well-liked and allegedly happy, but was also upset about a girl and had posted emotional social med"| __truncated__ NA ...
## $ WEAPONSOBTAINEDLEGALLY : chr [1:71] "Yes" "Yes" "No" NA ...
## $ WHEREWEAPONOBTAINED : chr [1:71] "On the internet, via Armslist.com" "Shooter's Choice gun store in West Columbia, South Carolina" "Gun was his father's." "Unknown" ...
## $ TYPEOFWEAPONS : chr [1:71] "2 assault rifles; semiautomatic handgun" "Handgun" "Handgun" "Two handguns and a butcher knife" ...
## $ NUMWEAPONS : num [1:71] 3 1 1 2 1 1 2 2 1 4 ...
## $ ASSAULT : chr [1:71] "Yes" "No" "No" "No" ...
## $ WEAPONDETAILS : chr [1:71] "AK-47, AR-15, and 30-round magazines; 9mm handgun" ".45-caliber Glock (model 41, with 13-round capacity magazine)" "Beretta .40-caliber handgun" "9mm semi-automatic handgun" ...
## $ SOURCES : chr [1:71] "http://www.reuters.com/article/2015/07/16/us-usa-shooting-tennessee-idUSKCN0PQ1WY20150716; http://www.nytimes.c"| __truncated__ "http://www.motherjones.com/politics/2015/06/dylann-roofs-attorney; http://www.newsweek.com/report-nine-shot-cha"| __truncated__ "http://www.seattletimes.com/seattle-news/fourth-marysville-shooting-victim-dies-as-another-is-laid-to-rest/ htt"| __truncated__ "http://www.sacbee.com/news/local/crime/article2603350.html; http://www.csmonitor.com/USA/2014/0223/Alturas-trib"| __truncated__ ...
## $ MENTALHEALTHSOURCES : chr [1:71] NA NA "http://www.newyorker.com/science/maria-konnikova/almost-link-mental-health-gun-violence" NA ...
## $ LATITUDE : num [1:71] 35 32.8 48.1 41.5 38.9 ...
## $ LONGITUDE : num [1:71] -85.3 -79.9 -122.2 -120.5 -77 ...
This dataset provides a series of useful information regarding the crime: its locations (longitude and latitude in degrees), the fatalities, how many injured, the type of weapon. For this project, only the coordinates and the type of crime are used.
dat <- dat[!is.na(dat$LONGITUDE)&!is.na(dat$LATITUDE),]
This data set will use all 72 observations provided from the original fil.
Since there are so many points on a map that it doesn’t make sense to plot every marker. So, plots of clusters of markers with addMarkers(clusterOptions = markerClusterOptions()) are used. You can zoom in to each cluster, the clusters will separate until you can see the individual markers. The Crime Type is added as a popup for each marker. Click on any blue marker to determine what crime was committed.
library(leaflet)
## Warning: package 'leaflet' was built under R version 3.2.5
dat %>%
leaflet() %>%
addTiles() %>%
addMarkers(popup=dat$Crime.type , clusterOptions=markerClusterOptions())
## Assuming 'Longitude' and 'Latitude' are longitude and latitude, respectively
In this project open crime data was displayed using Leaflet, one of the most popular Javascript libraries for creating interactive maps. However, in only a few lines of code, the leaflet R package allowed the creation of my own leaflet map without needing to know any Javascript!