-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbird-strike.Rmd
133 lines (90 loc) · 3.32 KB
/
bird-strike.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
---
title: "FAA Wildlife Strike Database"
author: "Dean Marchiori"
date: "7/23/2019"
output: html_document
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
library(tidyverse)
library(lubridate)
library(cowplot)
bird_impacts <- readr::read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-07-23/bird_impacts.csv")
```
```{r}
p1 <- bird_impacts %>%
select(time, time_of_day, species) %>%
filter(!is.na(time), time >= 0) %>%
mutate(time_char = as.character(paste0("000",time)),
species = fct_lump(species, 5)) %>%
mutate(hour = substr(time_char, nchar(time_char)-3, nchar(time_char)-2)) %>%
count(hour) %>%
mutate(ampm = ifelse(hour %in% c('00','01','02','03','04','05',
'06','07','08','09', '10','11'), "AM", "PM")) %>%
filter(ampm == "PM") %>%
ggplot(aes(hour, n, group = 1)) +
geom_line(colour = "#429bf5", alpha = 0.7, size = 1) +
scale_x_discrete(expand = c(0, 0)) +
labs(y = "",
x = "",
title = "PM") +
coord_polar() +
theme_dark() +
theme(axis.text.y = element_blank(),
axis.ticks.y = element_blank(),
plot.background = element_rect(fill = "transparent", colour = NA))
```
```{r}
p2 <- bird_impacts %>%
select(time, time_of_day, species) %>%
filter(!is.na(time), time >= 0) %>%
mutate(time_char = as.character(paste0("000",time)),
species = fct_lump(species, 5)) %>%
mutate(hour = substr(time_char, nchar(time_char)-3, nchar(time_char)-2)) %>%
count(hour) %>%
mutate(ampm = ifelse(hour %in% c('00','01','02','03','04','05',
'06','07','08','09', '10','11'), "AM", "PM")) %>%
filter(ampm == "AM") %>%
ggplot(aes(hour, n, group = 1)) +
geom_line(colour = "#ff7940", alpha = 0.7, size = 1) +
theme_dark() +
scale_x_discrete(expand = c(0, 0)) +
labs(y = "",
x = "",
title = "AM") +
coord_polar() +
theme(axis.text.y = element_blank(),
axis.ticks.y = element_blank(),
plot.background = element_rect(fill = "transparent", colour = NA))
```
```{r}
p3 <- bird_impacts %>%
select(phase_of_flt) %>%
mutate(phase_of_flt = str_to_lower(phase_of_flt)) %>%
count(phase_of_flt, sort = TRUE) %>%
filter(phase_of_flt != "unknown", !is.na(phase_of_flt)) %>%
mutate(phase_of_flt = fct_recode(phase_of_flt, approach = "arrival"),
phase_of_flt = fct_relevel(phase_of_flt, "taxi", "take-off run",
"departure", "climb", "en route", "descent",
"approach", "landing roll", "parked" )) %>%
ggplot(aes(phase_of_flt, n)) +
geom_col(fill = "#B5C949", alpha = 0.7) +
labs(title = "Bird Strike During Flight Phases",
subtitle = "FAA wildlife strike reports for the US big 4 airlines (1990 - present)",
x = "Flight Phase",
y = "Recorded Bird Strikes",
caption = "source: FAA Wildlife Strike Database") +
theme_dark() +
theme(plot.background = element_rect(fill = "grey50", colour = NA),
axis.text = element_text(colour = "grey20"))
```
```{r}
ggdraw() +
draw_plot(p3) +
draw_plot(p2, x = 0.1, y = 0.45, width = 0.2, height = 0.5) +
draw_plot(p1, x = 0.3, y = 0.45, width = 0.2, height = 0.5)
```