How do you find max/min of a non-numeric vector?

notgoodatstats

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!

dcarlson

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.

edited at
0

Comments

0 comments
Login to comment

Related

How do you get the magnitude of a vector in Numpy?

How do you get the magnitude of a vector in Numpy?

How do you set EditText to only accept numeric values in Android?

How do you find a float's nearest non-equal value?

How do you find duplicated elements of a vector that outputs the integer appearance of that duplicate instead of a logical?

How to find correlation coefficients for non-numeric variables

How to find non-numeric columns containing only numeric data?

Rails validation: How do you properly validate an invalid non-numeric input on a numeric field?

How do you merge numeric columns?

How do you or a vector with a single bit in verilog?

How Do I Mesh a Numeric Vector and a Character Matrix?

How do you enter variables with numeric names in SAS?

How do you Deflate data and put it into a vector?

How do I prevent R from coercing this vector of Dates to numeric?

How do you define a vector of a vector of a vector of doubles in C++?

How do I add sd field to to the summary of a numeric vector?

How to find and replace numeric rows in a character vector?

How do you use a vector in c++?

How do you parse a file into a vector of tokens?

How do you find the last non-zero number in an array?

How do you find or know where the "non-owned" entity type when trying to create a migration?

How to introduce non-numeric arguments in the same vector with numeric arguments for a reactable?

How do you find a string/char inside another string that's in a vector in C++? [that works for me]

R: How do I sort a dataframe based on a numeric vector?

How do you find an element in a Vector of tuples by comparing with a specific index in the tuple?

How do you convert all numeric strings in a dataframe to numeric in R?

How do you efficiently apply a numeric operation to an array in lua?

How do you add an icon resource using a numeric name to a TImageCollection?

How to fix regex to find non numeric value after newline character