简体   繁体   English

如何从数据集中获取一列,并根据另一列的最大值对其进行测试?

[英]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 .然后,您可以在检查结果时忽略第一行,因为它适用于tailnumNA值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何 plot 列子集与另一列的平均值? - How do I plot an average of a column subset against another column? 如何从数据集中取出一列,从另一个数据集中取出一列以过滤掉特定的东西? - How do I take one column from a data set and columns from anther data set to filter out a something specific? 如何根据数据框中的另一列计算一列的统计信息? - How to calculate stats for one column against another column in a data frame? 如何从 R 中的列中获取特定数字? - How do I take specific numbers from a column in R? 如何从一列中提取一部分数据并使用 R 将其粘贴到另一列中? - how do I extract a part of data from a column and and paste it n another column using R? 如何找到与另一列相关联的条件的一列的最大值 - How do I find the max of one column with a condition linked to another column 在 R 中,当另一列的总和小于常量时,如何选择一列的最大总和? - How do I choose the max sum of one column while the sum of another column is less than constant in R? 如何从公共ID中提取大型数据集中的行,并采用这些行的方式并创建具有这些ID的列 - How can I extract the rows from a large data set by common IDs and take the means of these rows and make a column having these IDs 如何从列中获取行值并根据不同的列值将它们组合起来,按“,”分隔? - How do I take row values from a column and combine them, sep by “,” based on different column value? .我想针对数据框中的每一列对每一列进行pairwise.t.test - .I want to do a pairwise.t.test of every column against every column in a dataframe
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM