This map shows the geographic distribution of 311 requests for Rodent Inspection and Treatment over the last 30 days in Washington, DC. Click on a region to zoom in further on the map. This application is focused on the public health concern that rodents pose to cities, with the data coming from DC’s Open Data Portal.
This visualization of 311 requests can help to identify areas of the city where rodents are more prevalent. By identifying open and closed tickets, this visual also shows what neighborhoods have more open tickets and can help identify if the DC DOH is administering their services equitably across the city.
An analysis of rodent 311 requests by Ward finds that not all wards have the same rate of incidence of rodent requests. This graph shows which wards have the most 311 requests for rodent issues as well as the share of those that are still open.
This visual plots the average response time for each 311 request by DC Ward.
First, this visual filters the total number of 311 requests for Rodent Inspection and Treatment to those that have been closed and measures the average number of days it takes DC’s DOH to close a ticket.
A comparison of responsibeness by Ward enables the community to have better insight into the quality of service they are receiving from the DC Department of Health (DOH) and how it compares to other regions of the city. If certain Wards are consistently getting faster response times than others, this may indicate that the service being administered by the DC DOH is not equitable, enabling local politicians and citizens to advocate for their neighborhoods.
This visual is part of a series that looks at a few of the potential drivers for increases in rodent incidence across DC. By visualizing Ward-level trends in each of these drivers, we can assess whether these drivers are positively correlated with rodent incidence within the District.
This specific visual examines the relationship between the population density of a Ward and the prevalence of rodent incidents. Population density is hypothesized to be correlated with higher incidence of rodent issues because with more people, there is more trash. Also, a denser area also increases the likelihood that those rodents in the area will come in contact with residents, where less dense areas may enable rodents to go unnoticed for longer.
Those factors in this series found to be most significantly correlated with increases in rodent incidence can help inform both the DOH and other city officials about what areas are likely to be hotspots for rodents in the future. With greater empirical insight into the correlative factors that drive increases in rodent issues, the city can better plan what regions are likely to have higher prevalence of requests and may be enabled to take preventative action.
This visual is part of a series that looks at a few of the potential drivers for increases in rodent incidence across DC. By visualizing Ward-level trends in each of these drivers, we can assess whether these drivers are positively correlated with rodent incidence within the District.
This specific visual examines the relationship between the number of building permits in a Ward and the prevalence of rodent incidents. Building permits are hypothesized to be associated with higher incidence of rodent problems because construction can draw rodents further out of their burrows and also often may be correlated with vacant or unattended properties, giving rodents a place to settle in.
Those factors in this series found to be most significantly correlated with increases in rodent incidence can help inform both the DOH and other city officials about what areas are likely to be hotspots for rodents in the future. With greater empirical insight into the correlative factors that drive increases in rodent issues, the city can better plan what regions are likely to have higher prevalence of requests and may be enabled to take preventative action.
This visual is part of a series that looks at a few of the potential drivers for increases in rodent incidence across DC. By visualizing Ward-level trends in each of these drivers, we can assess whether these drivers are positively correlated with rodent incidence within the District.
This specific visual examines the relationship between the number of grocery stores in a Ward and the prevalence of rodent incidents. Grocery stores are hypothesized to be a possible factor increasing rodent activity because they present a large single source of food, often with large dumpsters of excess or expired food in close proximity.
Those factors in this series found to be most significantly correlated with increases in rodent incidence can help inform both the DOH and other city officials about what areas are likely to be hotspots for rodents in the future. With greater empirical insight into the correlative factors that drive increases in rodent issues, the city can better plan what regions are likely to have higher prevalence of requests and may be enabled to take preventative action.
This is a map depicting the locations of grocery stores, public litter cans, and building permits throughout DC.
In a future iteration of RATRapp, more data could be added to this visual to add dynamic layers showing how the rodent incidents are correlated to specific drivers. This visual could have the ability for users to toggle through various drivers and see how they plot against rodent incidence.
Initial plots could include: grocery store locations (within half a mile), public litter can locations, building permit locations, zoning districts, and census tracts.
This visual plots distribution of response times for all tickets across DC.
A histogram distribution, such as this, enables users to see how long it usually takes for DC DOH to respond to a particular ticket. This is especially helpful for an individual citizen who is looking to track a 311 request they submitted and wants to know if the response time they received is within the normal range or if their service is outside of the norm for some reason.
[1] "Census"
RATRapp uses data from the DC Open Data Portal obtained through application processing interfaces (APIs) that update automatically as the DC Open Data Portal gets new information. Link: http://opendata.dc.gov/
This data includes:
311 requests for Rodent Inspection and Treatment from the last 30 days, as provided by the DC Department of Health: http://opendata.dc.gov/datasets/rodent-inspection-and-treatment-in-last-30-days/data
Ward boundaries and population statistics according to the 2010 and 2015 Census: http://opendata.dc.gov/datasets/ward-from-2012/data
Locations and information about public litter cans throughout DC, as maintained by the DC Department of Sanitation: http://opendata.dc.gov/datasets/litter-cans/data
Locations and basic information about grocery stores throughout DC: http://opendata.dc.gov/datasets/grocery-store-locations-1/data
Locations and information about building permits throughout DC submitted over the last 30 days, as maintained by the DC Department of Consumer and Regulatory Affairs: https://opendata.dc.gov/datasets/building-permits-in-last-30-days?orderBy=APPLICATION_STATUS_NAME&orderByAsc=false
Geospatial markers of zoning districts based on the DC government survey in 2016: http://opendata.dc.gov/datasets/zoning-regulations-of-2016/data
Some additional data on DC census tracts and populations and demographic data in each tract is from the US Census Bureau via the tidycensus R package. This data is available through the US Census Bureau’s APIs, and then packaged into a user-friendly manner in tidycensus with built-in commands for ease of access. About tidycensus: https://walkerke.github.io/tidycensus/
The Rodent Action Tracking Resource application, or RATRapp, is a Washington, DC-wide resource showing where 311 requests for Rodent Inspection and Treatment have been submitted. This application uses data from the DC Open Data Portal to visualize the extent of the rodent problem in DC as well as how effectively and equitably the DC Department of Health (DOH) is responding to the problem.
In brief, RATRapp is an application in the public health domain and supports the mission of the DC DOH to address burgeoning rat populations within the District. Rodents can carry disease, feed on garbage, and negatively impact the cleanliness of neighborhoods across the city. The DC DOH is running programs to target rodent issues, collecting 311 service requests and tracking their status. However, there is not currently a public resource to track these requests in aggregate or over time, which may allow DC DOH to gain insights into what factors are more likely to lead to problems, predicting hotspots, and taking more preventative actions. Additionally, this application will allow the DC citizenry to gain insight into how successfully DC DOH is addressing the rodent problem as well as how equitably these services are administered to neighborhoods across the city.
This application has three main user sets: DOH employees, DC citizens, and elected officials. First, the DC DOH employees working on these issues will be able to gain greater insight into the specific areas impacted by rodent problems as well as to self-assess the equity of service they provide. Second, the DC citizenry will gain transparency into the rodent problem, enabling them to better understand how their community is impacted and collectively advocate for better service. Third, DC elected officials from Wards or neighborhoods that are underserved currently or overrun by rodent request volume, will be in a position to make more informed decisions about policies across the city and advocate for their electorates.
RATRapp was created by Matthias Maier on April 8, 2019
---
title: "RATRapp: DC's Rodent Activity Tracking Resource Application"
output:
flexdashboard::flex_dashboard:
social: menu
source: embed
---
Home
=========================================
```{r setup, include=FALSE}
### SET UP LIBRARIES AND PACKAGES ###
#install.packages(c("geojsonsf"))
#install.packages(c("tidyverse", "tidycensus", "RSocrata", "httr", "magrittr", "viridis", "rjson", "crosstalk"))
library(flexdashboard)
library(leaflet)
library(jsonlite)
library(tidyverse)
library(tidycensus)
library(sf)
library(devtools)
library(ggmap)
library(sp)
library(ggplot2)
library(RSocrata)
library(httr)
library(magrittr)
library(dplyr)
library(viridis)
library(rjson)
library(lubridate)
library(crosstalk)
library(htmlwidgets)
library(htmltools)
library(geojsonsf)
### API CALLS ####
# census API data
census_api_key(key = "a6285f272eed1d84d2fe22e2b6f9faea71e21d91", install = TRUE, overwrite = TRUE)
census_var <- load_variables(2017, "acs5", cache = TRUE)
options(tigris_use_cache = TRUE)
census_raw <- get_acs(geography = "tract",
variables = (c("B02001_001", "B06011_001", "B02001_002")),
state = "DC",
geometry = TRUE)
# rodents last 30 days
rodent_full <- read_json("https://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_APPS/SR_30days_Open/MapServer/40/query?where=1%3D1&outFields=*&outSR=4326&f=json", simplifyVector = TRUE, flatten = TRUE)
# ward borders and population
wards_full <- read_json("https://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Administrative_Other_Boundaries_WebMercator/MapServer/31/query?where=1%3D1&outFields=*&outSR=4326&f=json",
simplifyVector = TRUE, flatten = TRUE)
ward_lines <- read_lines("https://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Administrative_Other_Boundaries_WebMercator/MapServer/31/query?where=1%3D1&outFields=*&outSR=4326&f=json") %>% paste(collapse = "\n")
# grocery stores in DC
grocery_full <- read_json("https://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Business_and_Economic_Development_WebMercator/MapServer/4/query?where=1%3D1&outFields=*&outSR=4326&f=json", simplifyVector = TRUE,
flatten = TRUE)
# public litter cans
litter_full <- read_json("https://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Public_Service_WebMercator/MapServer/10/query?where=1%3D1&outFields=*&outSR=4326&f=json", simplifyVector = TRUE, flatten = TRUE)
# zoning
zoning_full <- read_json("https://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Planning_Landuse_and_Zoning_WebMercator/MapServer/32/query?where=1%3D1&outFields=*&outSR=4326&f=json", simplifyVector = TRUE,
flatten = TRUE)
# construction permits
construct_full <- read_json("https://maps2.dcgis.dc.gov/dcgis/rest/services/FEEDS/DCRA/MapServer/4/query?where=1%3D1&outFields=*&outSR=4326&f=json", simplifyVector = TRUE, flatten = TRUE)
### ward lines additional attempt for lines
ward_lines <- read_lines("https://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Administrative_Other_Boundaries_WebMercator/MapServer/31/query?where=1%3D1&outFields=*&outSR=4326&f=json") %>% paste(collapse = "\n")
ward_json <- read_json("https://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Administrative_Other_Boundaries_WebMercator/MapServer/31/query?where=1%3D1&outFields=*&outSR=4326&f=json")
```
```{r wrangling, include=FALSE}
### DATA SET PROCESSING ###
# Leaflet Map - Census
census <- census_raw[c(1,2,3,4,6)]
census <- census %>% spread(variable, estimate)
colnames(census) <- c("GEOID", "Tract_Name", "Total_Pop", "White_Pop", "Med_Income", "geometry")
census$Share_White <- census$White_Pop / census$Total_Pop
census$Share_NW <- 1 - census$Share_White
df_census <- as.data.frame(census)
## rodent 311 data ##
# full 30 day set
df_rodent <- rodent_full$features
names(df_rodent) = gsub(pattern = "attributes.", replacement = "", x = names(df_rodent))
df_rodent$ADDDATE <- as.POSIXct(df_rodent$ADDDATE/1000, origin = "1970-01-01", tz = "GMT")
df_rodent$RESOLUTIONDATE <- as.POSIXct(df_rodent$RESOLUTIONDATE/1000, origin = "1970-01-01", tz = "GMT")
df_rodent$SERVICEDUEDATE <- as.POSIXct(df_rodent$SERVICEDUEDATE/1000, origin = "1970-01-01", tz = "GMT")
df_rodent$SERVICEORDERDATE <- as.POSIXct(df_rodent$SERVICEORDERDATE/1000, origin = "1970-01-01", tz = "GMT")
df_rodent$INSPECTIONDATE <- as.POSIXct(df_rodent$INSPECTIONDATE/1000, origin = "1970-01-01", tz = "GMT")
rodent <- df_rodent[c(1,3,5,7:12,14,15,17,19:22,25,27:29)]
rodent$DAYS_ELAPSED <- difftime(rodent$RESOLUTIONDATE, rodent$ADDDATE, units = c("days"))
rodent$DAYS_LATE <- difftime(rodent$RESOLUTIONDATE, rodent$SERVICEDUEDATE, units = c("days"))
rodent$WARD <- as.numeric(rodent$WARD)
# grouped by ward
rat_ward_sub <- rodent[c(18,21:22)]
##### need subset/average functions by ward
rat_ward_sub$COUNT <- 1
rat_ward <- rat_ward_sub %>% group_by(WARD) %>% summarize(COUNT_RAT = sum(COUNT),
AVG_DAYS = mean(as.numeric(DAYS_ELAPSED), na.rm=TRUE),
AVG_LATE = mean(as.numeric(DAYS_LATE), na.rm=TRUE))
## OTHER DATA SETS ##
# ward borders and population
df_ward <- wards_full$features
names(df_ward) = gsub(pattern = "attributes.", replacement = "", x = names(df_ward))
ward <- df_ward[c(2,11:17,49:50,72,81:83)]
ward$POP_DENS_15 <- ward$POP_2011_2015 / ward$AREASQMI
ward$POP_DENS_10 <- ward$POP_2010 / ward$AREASQMI
# grocery stores in DC
df_grocery <- grocery_full$features
names(df_grocery) = gsub(pattern = "attributes.", replacement = "", x = names(df_grocery))
grocery <- df_grocery[c(2,11:14,25:28)]
grocery$WARD <- gsub(pattern = "Ward ", replacement = "", x = grocery$WARD)
grocery$WARD <- as.numeric(grocery$WARD)
sub_groc <- grocery %>% filter(PRESENT18 == "Yes")
ward_groc <- sub_groc[c(5)]
ward_groc$COUNT <- 1
ward_groc <- ward_groc %>% group_by(WARD) %>% summarize(GROCERY = sum(COUNT))
# public litter cans
df_litter <- litter_full$features
names(df_litter) = gsub(pattern = "attributes.", replacement = "", x = names(df_litter))
df_litter$CREATEDAT <- as.POSIXct(df_litter$CREATEDAT/1000, origin = "1970-01-01", tz = "GMT")
litter <- df_litter[c(1,6,7,9,20:24)]
# zoning
df_zone <- zoning_full$features
names(df_zone) = gsub(pattern = "attributes.", replacement = "", x = names(df_zone))
zone <- df_zone[c(1,5,6,8,13)]
# construction permits
df_const <- construct_full$features
names(df_const) = gsub(pattern = "attributes.", replacement = "", x = names(df_const))
df_const$ISSUE_DATE <- as.POSIXct(df_const$ISSUE_DATE/1000, origin = "1970-01-01", tz = "GMT")
df_const$LASTMODIFIEDDATE <- as.POSIXct(df_const$LASTMODIFIEDDATE/100, origin = "1970-01-01", tz = "GMT")
const <- df_const[c(1,3,5,6,8,12,20,21,28)]
ward_con_long <- const[c(3,9)]
ward_con_long$COUNT <- 1
ward_con <- const[c(9)]
ward_con$COUNT <- 1
ward_con <- ward_con %>% group_by(WARD) %>% summarize(CONSTRUCTION = sum(COUNT))
### MERGE WARD-BASED DATA
wards <- merge(ward, rat_ward)
wards <- merge(wards, ward_con)
wards <- merge(wards, ward_groc)
#### WARD MAP LINES
ward_geom <- ward[c(14)]
ward_2 <- read_json("http://data.codefordc.org/dataset/a9512704-4ece-47cd-b3c0-402d28609364/resource/2aa4a2ff-dd55-45c7-b532-c949ccc77a03/download/dc-ward-map-overlay.topojson")
df_ward2 <- ward_2$objects$collection$geometries
c1 <- chartr('c()[]',' ', ward_geom)
m1 <- matrix(as.numeric(strsplit(c1,",")[[1]]),ncol=2,byrow=FALSE)
### zoning lines
zone_2 <- GET("https://github.com/benbalter/dc-maps/blob/master/maps/zoning-regulations-of-2016.geojson")
```
Column {data-width=100}
-----------------------------------------
### Rodent Incidents in 30 days
```{r}
total_count <- length(rodent$OBJECTID)
gauge(total_count, min = 0, max = 500, gaugeSectors(
success = c(0, 200), warning = c(200, 400), danger = c(400, 500)
))
```
### Request Completion Rate
```{r}
rodent_complete <- rodent %>% filter(rodent$STATUS_CODE == "CLOSED")
completion <- round(length(rodent_complete$OBJECTID) / length(rodent$OBJECTID) *100)
gauge(completion, min = 0, max = 100, symbol = '%', gaugeSectors(
success = c(95, 100), warning = c(75, 94), danger = c(0, 74)
))
```
### Request Inspection Rate
```{r}
rodent_inspected <- rodent_complete %>% filter(rodent_complete$INSPECTIONDATE < today())
inspection <- round(length(rodent_inspected$OBJECTID) / length(rodent_complete$OBJECTID) *100)
gauge(inspection, min = 0, max = 100, symbol = '%', gaugeSectors(
success = c(95, 100), warning = c(75, 94), danger = c(0, 74)
))
```
Column {data-width=200}
-----------------------------------------
```{r}
leaflet(rodent) %>%
addProviderTiles(provider = "CartoDB.Positron") %>%
setView(lng=-77, lat=38.9, zoom=11) %>%
addCircleMarkers(lng = rodent$LONGITUDE, lat = rodent$LATITUDE,
clusterOptions = markerClusterOptions(),
color = ~ifelse(rodent$STATUS_CODE == "OPEN", "#e9a3c9", "#a1d76a"), stroke = FALSE,
fillOpacity = 0.5, label = rodent$STATUS_CODE) %>%
addTopoJSON(ward_2, weight = 2, color = "#444444", fill = FALSE)
```
Column {data-width=150}
-----------------------------------------
***
This map shows the geographic distribution of 311 requests for Rodent Inspection and Treatment over the last 30 days in Washington, DC. Click on a region to zoom in further on the map. This application is focused on the public health concern that rodents pose to cities, with the data coming from DC's Open Data Portal.
This visualization of 311 requests can help to identify areas of the city where rodents are more prevalent. By identifying open and closed tickets, this visual also shows what neighborhoods have more open tickets and can help identify if the DC DOH is administering their services equitably across the city.
Details {.storyboard}
=========================================
### Rodent Requests by Ward
```{r}
library(plotly)
status_col <- ~ifelse(STATUS_CODE == "OPEN", "green", "blue")
legend_title <- "Request Status"
status <- ggplot(data = rodent, aes(x = WARD, fill = STATUS_CODE)) +
geom_bar() + guides(fill=guide_legend("Request Status")) +
theme(
panel.background = element_blank(),
axis.ticks = element_blank(),
axis.text = element_text(size=12),
plot.title = element_text(size=16),
plot.subtitle = element_text(size=12),
axis.title = element_text(size=12)) +
labs(
y = "Number of Service Requests",
x = "DC Ward")
ggplotly(status)
```
***
An analysis of rodent 311 requests by Ward finds that not all wards have the same rate of incidence of rodent requests. This graph shows which wards have the most 311 requests for rodent issues as well as the share of those that are still open.
### DC DOH Average Time to Respond by Ward
```{r}
library(plotly)
complete_time <- ggplot(data = wards, aes(x = WARD, y = AVG_DAYS)) +
geom_bar(stat = "identity", fill = "#3182bd") +
theme(
panel.background = element_blank(),
axis.ticks = element_blank(),
axis.text = element_text(size=12),
plot.title = element_text(size=16),
plot.subtitle = element_text(size=12),
axis.title = element_text(size=12)) +
labs(
y = "Average Number of Days to Resolve",
x = "DC Ward")
ggplotly(complete_time)
```
***
This visual plots the average response time for each 311 request by DC Ward.
First, this visual filters the total number of 311 requests for Rodent Inspection and Treatment to those that have been closed and measures the average number of days it takes DC's DOH to close a ticket.
A comparison of responsibeness by Ward enables the community to have better insight into the quality of service they are receiving from the DC Department of Health (DOH) and how it compares to other regions of the city. If certain Wards are consistently getting faster response times than others, this may indicate that the service being administered by the DC DOH is not equitable, enabling local politicians and citizens to advocate for their neighborhoods.
### Population Density and Rat Incidence by Ward
```{r}
library(plotly)
f <- list(
family = "Courier New, monospace",
size = 18,
color = "#7f7f7f"
)
x <- list(
title = "Ward Area (Square Miles)",
titlefont = f
)
y <- list(
title = " 2015 Population Density (K/SqMi)",
titlefont = f
)
fit <- lm(POP_DENS_15 ~ AREASQMI, data = wards)
plot_ly(wards, x = ~AREASQMI, y = ~POP_DENS_15, type = 'scatter', mode = 'markers',
hoverinfo = 'text', text = ~paste('Ward', WARD,'
Number of Incidents:', COUNT_RAT),
marker = list(size = ~COUNT_RAT, opacity = 0.5, color = 'rgb(255, 65, 54)')) %>%
layout(xaxis = x,yaxis = y) %>%
add_trace(x = ~AREASQMI, y = fitted(fit), mode = "lines")
```
***
This visual is part of a series that looks at a few of the potential drivers for increases in rodent incidence across DC. By visualizing Ward-level trends in each of these drivers, we can assess whether these drivers are positively correlated with rodent incidence within the District.
This specific visual examines the relationship between the population density of a Ward and the prevalence of rodent incidents. Population density is hypothesized to be correlated with higher incidence of rodent issues because with more people, there is more trash. Also, a denser area also increases the likelihood that those rodents in the area will come in contact with residents, where less dense areas may enable rodents to go unnoticed for longer.
Those factors in this series found to be most significantly correlated with increases in rodent incidence can help inform both the DOH and other city officials about what areas are likely to be hotspots for rodents in the future. With greater empirical insight into the correlative factors that drive increases in rodent issues, the city can better plan what regions are likely to have higher prevalence of requests and may be enabled to take preventative action.
### Building Permits and Rat Incidence by Ward
```{r}
library(plotly)
plot_ly(wards, x = ~COUNT_RAT, y = ~CONSTRUCTION, type = 'scatter', mode = 'markers',
hoverinfo = 'text', text = ~paste('Ward', WARD,'
Number of Incidents:', COUNT_RAT),
marker = list(size = ~COUNT_RAT, opacity = 0.5, color = 'rgb(255, 65, 54)')) %>%
layout(xaxis = list(showgrid = FALSE),yaxis = list(showgrid = FALSE))
```
***
This visual is part of a series that looks at a few of the potential drivers for increases in rodent incidence across DC. By visualizing Ward-level trends in each of these drivers, we can assess whether these drivers are positively correlated with rodent incidence within the District.
This specific visual examines the relationship between the number of building permits in a Ward and the prevalence of rodent incidents. Building permits are hypothesized to be associated with higher incidence of rodent problems because construction can draw rodents further out of their burrows and also often may be correlated with vacant or unattended properties, giving rodents a place to settle in.
Those factors in this series found to be most significantly correlated with increases in rodent incidence can help inform both the DOH and other city officials about what areas are likely to be hotspots for rodents in the future. With greater empirical insight into the correlative factors that drive increases in rodent issues, the city can better plan what regions are likely to have higher prevalence of requests and may be enabled to take preventative action.
### Grocery Stores and Rat Incidence by Ward
```{r}
library(plotly)
plot_ly(wards, x = ~COUNT_RAT, y = ~GROCERY, type = 'scatter', mode = 'markers',
hoverinfo = 'text', text = ~paste('Ward', WARD,'
Number of Incidents:', COUNT_RAT),
marker = list(size = ~COUNT_RAT, opacity = 0.5, color = 'rgb(255, 65, 54)')) %>%
layout(xaxis = list(showgrid = FALSE),yaxis = list(showgrid = FALSE))
```
***
This visual is part of a series that looks at a few of the potential drivers for increases in rodent incidence across DC. By visualizing Ward-level trends in each of these drivers, we can assess whether these drivers are positively correlated with rodent incidence within the District.
This specific visual examines the relationship between the number of grocery stores in a Ward and the prevalence of rodent incidents. Grocery stores are hypothesized to be a possible factor increasing rodent activity because they present a large single source of food, often with large dumpsters of excess or expired food in close proximity.
Those factors in this series found to be most significantly correlated with increases in rodent incidence can help inform both the DOH and other city officials about what areas are likely to be hotspots for rodents in the future. With greater empirical insight into the correlative factors that drive increases in rodent issues, the city can better plan what regions are likely to have higher prevalence of requests and may be enabled to take preventative action.
### Mapping Other Drivers of Rodent Incidents
```{r, include = FALSE}
#zone %>%
# ggplot(aes(fill = POP_DENS_15, color = POP_DENS_15)) +
# geom_sf() +
# coord_sf(crs = 26911) +
# scale_fill_viridis(option = "magma") +
# scale_color_viridis(option = "magma")
sub_groc2 <- sub_groc[c(1,8,9)]
sub_groc2$type <- print("grocery")
colnames(sub_groc2) <- c("Name", "Longitude", "Latitude", "Type")
sub_litter <- litter[c(1,8,9)]
sub_litter$type <- print("litter")
colnames(sub_litter) <- c("Name", "Longitude", "Latitude", "Type")
sub_litter$Name <- paste("Can", sub_litter$Name, sep="_")
groc_litter <- rbind(sub_groc2, sub_litter)
sub_cons <- const[c(1,7,8)]
sub_cons$type <- print("construction")
colnames(sub_cons) <- c("Name", "Longitude", "Latitude", "Type")
drivers <- rbind(groc_litter, sub_cons)
gl_pal <- c()
for (i in 1:length(drivers$Type)) {
if (drivers$Type[i] == "grocery") {
col <- "green"
} else if (drivers$Type[i] == "litter") {
col <- "gray"
} else if (drivers$Type[i] == "construction") {
col <- "blue"
} else {
col <- "white"
}
gl_pal <- c(gl_pal, col)
}
```
```{r}
leaflet() %>%
addProviderTiles(provider = "CartoDB.Positron") %>%
setView(lng=-77, lat=38.9, zoom=11) %>%
addCircleMarkers(lng = drivers$Longitude, lat = drivers$Latitude,
radius = 3,
stroke = FALSE, fillOpacity = 0.5, fillColor = gl_pal) %>%
addTopoJSON(ward_2, weight = 2, color = "#444444", fill = FALSE)
```
***
This is a map depicting the locations of grocery stores, public litter cans, and building permits throughout DC.
In a future iteration of RATRapp, more data could be added to this visual to add dynamic layers showing how the rodent incidents are correlated to specific drivers. This visual could have the ability for users to toggle through various drivers and see how they plot against rodent incidence.
Initial plots could include: grocery store locations (within half a mile), public litter can locations, building permit locations, zoning districts, and census tracts.
### DC DOH Responsiveness to Rodent Inspection and Treatment Requests
```{r}
library(plotly)
#plot_ly(x = rodent$DAYS_ELAPSED, type = "histogram") %>%
# labels( = "Days to Complete", ylab = "Number of Requests")
p <- ggplot(data = rodent, aes(x = DAYS_ELAPSED)) +
geom_histogram(binwidth = 1, fill = "#67a9cf", col = "white") +
theme(
panel.background = element_blank(),
axis.ticks = element_blank(),
axis.text = element_text(size=12),
plot.title = element_text(size=16),
plot.subtitle = element_text(size=12),
axis.title = element_text(size=12)) +
labs(
y = "Number of Requests",
x = "Days to Complete")
ggplotly(p)
```
***
This visual plots distribution of response times for all tickets across DC.
A histogram distribution, such as this, enables users to see how long it usually takes for DC DOH to respond to a particular ticket. This is especially helpful for an individual citizen who is looking to track a 311 request they submitted and wants to know if the response time they received is within the normal range or if their service is outside of the norm for some reason.
Data Sources
=========================================
Column
------------------------------------------
### Get the Raw Data
```{r}
library(shiny)
ui <- fluidPage(
# App title ----
titlePanel("Downloading Data"),
# Sidebar layout with input and output definitions ----
sidebarLayout(
# Sidebar panel for inputs ----
sidebarPanel(
# Input: Choose dataset ----
selectInput("dataset", "Choose a dataset:",
choices = c("Rodent 311", "Ward", "Grocery", "Litter Cans", "Construction", "Zones",
"Census")),
# Button
downloadButton("downloadData", "Download")
),
# Main panel for displaying outputs ----
mainPanel(
tableOutput("table")
)
)
)
server <- function(input, output) {
# Reactive value for selected dataset ----
datasetInput <- reactive({
switch(input$dataset,
"Rodent 311" = rodent,
"Ward" = ward,
"Grocery" = grocery,
"Litter Cans" = litter,
"Construction" = const,
"Zones" = zone,
"Census" = census)
})
# Table of selected dataset ----
output$table <- renderTable({
datasetInput()
})
# Downloadable csv of selected dataset ----
output$downloadData <- downloadHandler(
filename = function() {
paste(input$dataset, ".csv", sep = "")
},
content = function(file) {
write.csv(datasetInput(), file, row.names = FALSE)
}
)
}
shinyApp(ui, server)
# "Rodent 311", "Ward", "Grocery", "Litter Cans", "Construction", "Zones",
"Census"
```
Column
------------------------------------------
### About the Data
***
RATRapp uses data from the DC Open Data Portal obtained through application processing interfaces (APIs) that update automatically as the DC Open Data Portal gets new information. Link: http://opendata.dc.gov/
This data includes:
311 requests for Rodent Inspection and Treatment from the last 30 days, as provided by the DC Department of Health: http://opendata.dc.gov/datasets/rodent-inspection-and-treatment-in-last-30-days/data
Ward boundaries and population statistics according to the 2010 and 2015 Census: http://opendata.dc.gov/datasets/ward-from-2012/data
Locations and information about public litter cans throughout DC, as maintained by the DC Department of Sanitation: http://opendata.dc.gov/datasets/litter-cans/data
Locations and basic information about grocery stores throughout DC: http://opendata.dc.gov/datasets/grocery-store-locations-1/data
Locations and information about building permits throughout DC submitted over the last 30 days, as maintained by the DC Department of Consumer and Regulatory Affairs: https://opendata.dc.gov/datasets/building-permits-in-last-30-days?orderBy=APPLICATION_STATUS_NAME&orderByAsc=false
Geospatial markers of zoning districts based on the DC government survey in 2016: http://opendata.dc.gov/datasets/zoning-regulations-of-2016/data
Some additional data on DC census tracts and populations and demographic data in each tract is from the US Census Bureau via the tidycensus R package. This data is available through the US Census Bureau’s APIs, and then packaged into a user-friendly manner in tidycensus with built-in commands for ease of access. About tidycensus: https://walkerke.github.io/tidycensus/
About
=========================================
### About RATRapp
***
The Rodent Action Tracking Resource application, or RATRapp, is a Washington, DC-wide resource showing where 311 requests for Rodent Inspection and Treatment have been submitted. This application uses data from the DC Open Data Portal to visualize the extent of the rodent problem in DC as well as how effectively and equitably the DC Department of Health (DOH) is responding to the problem.
In brief, RATRapp is an application in the public health domain and supports the mission of the DC DOH to address burgeoning rat populations within the District. Rodents can carry disease, feed on garbage, and negatively impact the cleanliness of neighborhoods across the city. The DC DOH is running programs to target rodent issues, collecting 311 service requests and tracking their status. However, there is not currently a public resource to track these requests in aggregate or over time, which may allow DC DOH to gain insights into what factors are more likely to lead to problems, predicting hotspots, and taking more preventative actions. Additionally, this application will allow the DC citizenry to gain insight into how successfully DC DOH is addressing the rodent problem as well as how equitably these services are administered to neighborhoods across the city.
This application has three main user sets: DOH employees, DC citizens, and elected officials. First, the DC DOH employees working on these issues will be able to gain greater insight into the specific areas impacted by rodent problems as well as to self-assess the equity of service they provide. Second, the DC citizenry will gain transparency into the rodent problem, enabling them to better understand how their community is impacted and collectively advocate for better service. Third, DC elected officials from Wards or neighborhoods that are underserved currently or overrun by rodent request volume, will be in a position to make more informed decisions about policies across the city and advocate for their electorates.
RATRapp was created by Matthias Maier on April 8, 2019