[英]How do I take a column from a data set, and test it against the max of another column?
I am currently working in the package nyclflights13, data set flights.我目前在 package nyclflights13 工作,数据集航班。 There is a column for the name of a plane, and a column for how many times that plane flew.有一列是飞机的名称,一列是那架飞机飞行了多少次。 I want to know which plane flew the most amount of times.我想知道哪架飞机飞行次数最多。 Also I would like to omit any missing values, ie any NA;s.此外,我想省略任何缺失值,即任何 NA;s。
I know that I am going to have to use the summarise () function and the select function with a - to omit the missing values.我知道我将不得不使用带有 - 的 summarise () function 和 select function 来省略缺失值。 I'm just not sure how to do that exactly.我只是不确定如何做到这一点。
I used this code to tally the number of rows in flights
with each value of tailnum
.我使用此代码来计算flights
中每个tailnum
值的行数。
library(magrittr)
library(nycflights13)
data(flights)
flights %>%
dplyr::group_by(tailnum) %>%
dplyr::tally() %>%
dplyr::arrange(desc(n))
You can then ignore the top row when examining the results, as it is for NA
values of tailnum
.然后,您可以在检查结果时忽略第一行,因为它适用于tailnum
的NA
值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.