在 R 中的嵌套数据框中查找重复值

Find duplicated values in a nested dataframe in R

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

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

library(tidyverse)

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

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

你应该先 count 然后再服用 distinct。尝试:

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