【问题标题】:Select two certain values of a column in R RStudio [closed]在R RStudio中选择一列的两个特定值[关闭]
【发布时间】:2020-08-03 15:25:59
【问题描述】:

这是关于来自 R 的数据集 MplsStops。

我选择了我需要的数据集的两列:race 和 citationIssued。

在那之后,我省略了所有的 NA。

然后我想通过列比赛中的黑白值过滤所有 citationIssued 值。

我怎样才能做到这一点?

感谢您的帮助

【问题讨论】:

    标签: r select filter subset


    【解决方案1】:

    欢迎来到 Stack Overflow!

    如果您想通过R 学习数据处理,dplyr 包是您的朋友。

    这个怎么样:

    library(carData)  # get the sample data
    
    library(dplyr)  # load dplyr for data processing functions
    MplsStops %>%  # start with the data and pipe it to the next line
      select(race, citationIssued) %>%  #  keep two variables and pipe to next line
      filter(race %in% c("Black", "White") & !is.na(citationIssued))
    

    如果回答,请点击绿色复选标记,如果没有,请添加评论以获得更多帮助。

    【讨论】:

      猜你喜欢
      • 2022-10-14
      • 2021-08-23
      • 1970-01-01
      • 1970-01-01
      • 2021-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多