library(dplyr)
library(ggplot2)
library(forcats)
library(tidyr)
# Phase of the flight during which the collision occurred, tabular
birds %>%
count(phase_of_flt, sort = TRUE)
# Phase of the flight during which the collision occurred, barplot
ggplot(birds, aes(y = fct_infreq(phase_of_flt))) +
geom_bar() +
labs(x = "Phase of flight")
# Height summary statistics
summary(birds$height)
# Phase of flight vs. effect of crash
birds %>%
drop_na(phase_of_flt, effect) %>%
ggplot(aes(y = phase_of_flt, fill = effect)) +
geom_bar(position = "fill") +
labs(x = "Proportion", y = "Phase of flight", fill = "Effect")
Run the code above in your browser using DataLab