Reputation: 796
I have the follow df
:
set.seed(126)
df <- data.frame(
x = replicate(2, sample(1:25, 25, replace = TRUE))
)
For return distinct values:
library(tidyverse)
library(magrittr)
df %>% distinct(x.1) %>% count()
# A tibble: 1 x 1
n
<int>
1 17
But, I want return duplicated values, instead distincts. I try:
df %>% !distinct(x.1) %>% count()
Error in distinct(x.1) : object 'x.1' not found
df %>% negate(distinct(x.1)) %>% count()
Error: Can't convert a
data.frame
object to function
df_1 %>% not(distinct(x.1)) %>% count()
Error in distinct(x.1) : object 'x.1' not found
tidyverse
functions.Upvotes: 0
Views: 170
Reputation: 40171
You can try:
df %>%
filter(duplicated(x.1)) %>%
count()
n
<int>
1 10
Upvotes: 3