我有下面的df
set.seed(126)
df <- data.frame(
x = replicate(2, sample(1:25, 25, replace = TRUE))
)对于返回不同的值:
library(tidyverse)
library(magrittr)
df %>% distinct(x.1) %>% count()
# A tibble: 1 x 1
n
<int>
1 17但是,我希望返回重复的值,而不是区别。我试着:
df %>% !distinct(x.1) %>% count()distinct(x.1)中的错误:找不到对象'x.1‘
df %>% negate(distinct(x.1)) %>% count()错误:无法将
data.frame对象转换为函数
df_1 %>% not(distinct(x.1)) %>% count()distinct(x.1)中的错误:找不到对象'x.1‘
tidyverse函数的函数。发布于 2019-04-10 15:08:06
你可以试试:
df %>%
filter(duplicated(x.1)) %>%
count()
n
<int>
1 10https://stackoverflow.com/questions/55615811
复制相似问题