【问题标题】:Find duplicated values in a nested dataframe in R在 R 的嵌套数据框中查找重复值
【发布时间】:2020-12-01 05:16:30
【问题描述】:

在下面的 data.frame 中,我想知道是否有任何 childid 具有多个 grade 相同值的实例。

但我不确定我的代码是否正确?

library(tidyverse)

dd <- read.csv('https://raw.githubusercontent.com/rnorouzian/e/master/3.csv')

dd %>% distinct(childid, grade) %>% 
  count(grade) %>% filter(n>1)

【问题讨论】:

    标签: r dataframe dplyr tidyverse tibble


    【解决方案1】:

    您应该先count,然后再使用distinct。试试看:

    library(dplyr)
    dd %>%
      count(childid, grade) %>%
      filter(n > 1) %>%
      distinct(childid)
    

    【讨论】:

    • 谢谢你,Ronak,等待接受,你看到我关于你的解决方案的问题HERE了吗? (向下滚动查看评论部分)
    猜你喜欢
    • 2019-07-02
    • 2023-04-05
    • 2013-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-07
    • 2019-01-09
    相关资源
    最近更新 更多