-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.Rmd
147 lines (113 loc) · 5.33 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
---
title : "Houston Crime Explorer"
author: "Luke Smith"
date : "`r Sys.Date()`"
output:
md_document:
variant: markdown_github
# word_document
---
## Houston Crime Explorer
[The app](https://seasmith.shinyapps.io/HoustonCrimeViewer) allows you to explore the City of Houston crime data set through the use of an interactive choropleth map, line charts, histograms, and an hour-by-hour heatmap. All instances of crime rate refer to the rate per 100,000 persons.
__NOTE:__
* This app is not mobile ready. Sorry. Pop-ups are sticky; I will get around to fixing this.
* If using Firefox, you will have to select a 'Crime Category' to populate the choropleth map. For whatever reason, the app does not auto-populate the map with the default 'Aggravated Assaults' category.
### Tour
The choropleth map gives you a tooltip with some helpful information.
![Tooltip](imgs/tooltip.gif)
Selecting police beats on the map changes the output of the plots.
![Select Beat](imgs/beat_selection.gif)
![Select Beat](imgs/beat_selection_2.gif)
Deselecting the police beat resets the plots.
![Deselect Beat](imgs/beat_deselection.gif)
The map changes when the crime type is changed.
![Select Crime Type](imgs/type_selection.gif)
You can also change the year.
![Select Year](imgs/year_selection.gif)
### Build It
The app is available [online](https://seasmith.shinyapp.io/HoustonCrimeViewer). However, you can run this app yourself.
To run the app, you will need to:
1. [Install R](https://cran.r-project.org/)
2. [Install RStudio](https://www.rstudio.com/products/rstudio/download/#download)
3. [Install Git](https://git-scm.com/downloads)
4. Clone this project: `git clone https://github.com/seasmith/HoustonCrimeViewer HoustonCrimeViewer`
5. Install `devtools` and `packrat`: `install.packages(c("devtools", "packrat"))`
6. Install requisite packages: `packrat::init()` or `devtools::install_deps()` (the `DESCRIPTION` file exists for this purpose, this repo is __not__ a package)
7. Execute `shiny::runApp()`
Please create an issue if something does not go as planned.
## Future Versions
### Definitive Additions
Some things which __will__ eventually be added:
* A 'data brief' section to document:
* Data distribution
* Missing/anomalous data
* `plotly` maps.
* Lasso-selection
* Multi-selection
* Satellite imagery
* Start- and end-year range selection.
* Currently, the server gets hung up when the slider is used. May have to resort to using another dropdown menu.
* School district polygons. This may make the map look a little messy, so this may be placed in its own separate map or as a static report per school district.
* Toggle certain beats that skew the crime rates. Right now, this is pre-set (the grayed-out polygons).
* Select which variable to map. Currently `rate` is used, but others may include:
* `n_offenses` (number of offenses)
* `n_offenses / pop_den` (number of offenses divided by population density)
* Attach names to the police beats:
Police Beat | Name
------------| ----
1A20 | West Montrose
1A30 | East Montrose
1A40 | River Oaks
1A50 | Afton Oaks
2A20 | The Heights (East)
2A30 | The Heights (Central)
2A40 | First Ward
2A50 | Rice Military
2A60 | The Heights (West)
3B30 | Oak Forest
3B40 | Independence Heights
4F30 | Addicks Reservoir
6B60 | Greenspoint
10H40 | Midtown
10H50 | Third Ward (University of Houston)
10H70 | Museum District
12D50 | Clear Lake (North)
12D60 | Clear Lake (Central)
10H80 | Rice Village
14D20 | Sunnyside
15E40 | The Astrodome
17E10 | Gulfton
18F10 | Tanglewood (Houston)
18F20 | The Galleria
18F30 | Fountainview
18F40 | Piney Point
19G10 | Alief (East)
19G20 | Alief (Central)
19G30 | Alief (West)
19G40 | Alief (South)
20G30 | West Chase
20G50 | City Centre
20G60 | Memorial
20G80 | Barker Reservoir
### Probable Additions
Some things which __may__ be added:
* Address input. Ideally, a user should be able to enter their address to highlight the police beat in which the live.
* Geocoding all crimes. There are hundreds of thousands of unique block ranges (block ranges are the addressing method used by the Houston Police Department). Focus may be prioritized on recent years, starting with 2017.
* Census data. This may include income, age, race, and other data available through the census.
* Turn this project into a package. Vignettes would act as reports and summaries.
* Vega/Vega-lite graphics.
## Other Visuals
I have posted tweets on this data in the past, and likely will continue to do so.
> [Crime in \#Houston from 2010-2017 and Hurricane Harvey's impact \#rstats](https://twitter.com/lksmth/status/970721936295845889)
> - March 5, 2018
![The Harvey Effect](imgs/the_harvey_effect_annotated.png)
![Monthly Heatmap](imgs/houston_crime_per_month.png)
## Data sources
Type | Source
-----|-------
Crime data | [City of Houston][source_crime]
Police beats | [City of Houston][source_police_beats]
Population data | [NASA SEDAC][source_nasa_sedac]
[source_crime]: http://www.houstontx.gov/police/cs/crime-stats-archives.htm
[source_police_beats]: https://cohgis-mycity.opendata.arcgis.com/datasets/houston-police-beats
[source_nasa_sedac]: http://sedac.ciesin.columbia.edu/data/collection/gpw-v4