Hello, I'm using the
nycflights13 data set and I would like to highlight the worst two carriers per origin airport by the 75th percentile of departure delays. I can't seem to find a way to do this. I was going to create a quantile column where and then try to create a boolean value that marks if that carrier is the bottom two per each origin airport. Any ideas on how I could do this?
library(tidyverse) library(nycflights13) flights %>% filter(sched_dep_time <= 1200) %>% group_by(carrier, origin) %>% mutate(q3 = quantile(dep_delay, probs = 0.75, na.rm = T), rank = rank(desc(q3)), top_2 = ifelse(rank %in% c(1,2), TRUE, FALSE)) %>% View()