0

I have used the following code in order to produce a table showing me the number of duplicates for the serial variable of my dataframe:

des_serial_duplicates <- filter(des_selected2, duplicated(serial))
desinventar_duplicates <- des_serial_duplicates %>% count(serial)
head(desinventar_duplicates)

Yet, the desinventar_duplicates df created seems to include observations which appear only once (non duplicates, see for instance first two lines of head(desinventar_duplicates) here : r screenshot

Am reading the results incorrectly ? How can I solve this ?

Cath
  • 23,906
  • 5
  • 52
  • 86
  • Hi! What exactly is your desired output ? Do you need information like `table(des_serial_duplicates$serial)[table(des_serial_duplicates$serial)>1]` ? – Cath Sep 18 '20 at 15:17
  • Welcome to SO! Please provide some test data, otherwise it's difficult to help you. See [how to make a minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – starja Sep 18 '20 at 15:18
  • Consider `duplicated(c(1, 1, 2, 3, 4, 5, 5))` – Hugh Sep 18 '20 at 15:20
  • @Cath thanks, this seems to be what I was looking for. I am still wondering why sum(duplicated(des_selected2$serial)) include some observations with n = 1 (non duplicates?), do you have any idea why ? – Charlotte G Sep 19 '20 at 16:12

0 Answers0