-
Notifications
You must be signed in to change notification settings - Fork 1
/
map.Rmd
167 lines (130 loc) · 3.98 KB
/
map.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
---
title: "Location of Delay in NY"
output:
html_document:
code_folding: hide
toc: true
toc_float: true
always_allow_html: true
css: style.css
---
```{r setup, include=FALSE}
library(tidyverse)
library(httr)
library(plotly)
library(readr)
library(knitr)
knitr::opts_chunk$set(
echo = TRUE,
warning = FALSE,
fig.width = 8,
fig.height = 6,
out.width = "90%"
)
theme_set(theme_minimal() + theme(legend.position = "bottom"))
options(
ggplot2.continuous.colour = "viridis",
ggplot2.continuous.fill = "viridis"
)
scale_colour_discrete = scale_color_viridis_d
scale_fill_discrete = scale_fill_viridis_d
```
```{r,message=FALSE,warning=FALSE}
opt_delay = read_csv("./data/opt_delay.csv")%>%
distinct(school_name,.keep_all = TRUE)
```
# Count Data
There are a total of `r nrow(opt_delay)` schools analyzed in this dataset with complete location data from 2015 and 2021.
## Average Delayed Time
It is a table showing that how many schools are in each average delay time level in New York from 2015 to 2021.
```{r}
avergae_delayed = data.frame(opt_delay %>% count(how_long_delayed))
avergae_delayed %>%
rename(frequency = n) %>%
knitr::kable()
```
# Maps
## Manhattan Map Reference
For reference, here is a helpful map of the neighborhoods in New York
[Source: MapsNewYork](https://jennisparks.com/hand-drawn-map-of-new-york)
```{r, echo=FALSE, out.width="50%", fig.cap="New York Map", fig.align = 'center'}
knitr::include_graphics("./data/newyorkmap.jpeg")
```
These maps include data provided by New York City in the open source crash database and data.world, generated by Plotly Chart Studio and Mapbox geolocation software.
## School Bus Delayed in New York
This map displays the geolocation of school buses delayed in New York City from 2015 to 2021.
The school buses in Manhattan averagely have a longer delayed time.
```{r}
# plot
map_school =
opt_delay %>%
mutate(school_delay = str_c(school_name,",",how_long_delayed)) %>%
plot_ly(
lat = ~latitude,
lon = ~longitude,
color = ~how_long_delayed,
colors = "Set1",
marker = list(color = "dark"),
type = 'scattermapbox',
hovertext = ~school_delay,
mode = 'markers')
map_school =
map_school %>%
layout(
mapbox = list(
style = 'open-street-map',
zoom =9,
center = list(lon = -73.93, lat = 40.71)))
map_school
```
# When We Focus on Manhanttan...
```{r}
# plot
map_school_manhattan =
opt_delay %>%
filter(city == "Manhattan") %>%
mutate(school_delay = str_c(school_name,",",how_long_delayed)) %>%
plot_ly(
lat = ~latitude,
lon = ~longitude,
color = ~how_long_delayed,
colors = "Set1",
marker = list(color = "dark"),
type = 'scattermapbox',
hovertext = ~school_delay,
mode = 'markers')
map_school_manhattan =
map_school_manhattan %>%
layout(
mapbox = list(
style = 'open-street-map',
zoom =10,
center = list(lon = -73.96, lat = 40.77)))
map_school_manhattan
```
# Density Heatmaps
These maps include data provided by New York City in the open-source crash database and `data.world`, generated by Plotly Chart Studio and Mapbox geolocation software.
```{r}
map_school_manhattan_density =
opt_delay %>%
filter(city == "Manhattan") %>%
mutate(school_delay = str_c(school_name,",",how_long_delayed)) %>%
plot_ly(
lat = ~latitude,
lon = ~longitude,
color = ~how_long_delayed,
marker = list(color = "dark"),
type = 'densitymapbox',
radius = 3)
map_school_manhattan_density =
map_school_manhattan_density %>%
layout(
mapbox = list(
style = 'open-street-map',
zoom =8,
center = list(lon = -73.96, lat = 40.77)),
title = "Density Heatmap of School Buses delayed in Manhattan")
map_school_manhattan_density
```
# Summary
Data in these geolocation and density heatmap plots help identify certain schools in New York City that appear to have more severe school bus delayed. They are around East Harlem and Lower East Side, as well as the Hudson Yards.