I'm trying to answer a homework problem, and I'm not very good at R Studio. The problem involves the nycflights13 dataset. The question is, "Using the flights data, identify which airline carrier had the most flights in 2013? Which had the fewest number of flights? Do this using max() and min()."
So far I've used this:
table(nycflights13::flights$carrier)
It's helped me retrieve a frequency table of the carriers. I know United Airlines has the most and Skywest has the least. But how do I prove this using max() and min()? It has only returned the highest and lowest alphabetical values of the carriers. Thank you!
Just identify which values in your table are minimums and maximums (there may be only one of each):
tbl <- table(nycflights13::flights$carrier)
minval <- min(tbl)
maxval <- max(tbl)
tbl[which(tbl == minval)]
tbl[which(tbl == maxval)]
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments