Skip to content
Prev 378365 / 398502 Next

duplicates including first occurrence

Hello,

Simply OR (|) both conditions.

mtcars[duplicated(mtcars$wt) | duplicated(mtcars$wt,fromLast=TRUE),]
#                   mpg cyl  disp  hp drat   wt  qsec vs am gear carb
#Hornet Sportabout 18.7   8 360.0 175 3.15 3.44 17.02  0  0    3    2
#Duster 360        14.3   8 360.0 245 3.21 3.57 15.84  0  0    3    4
#Merc 280          19.2   6 167.6 123 3.92 3.44 18.30  1  0    4    4
#Merc 280C         17.8   6 167.6 123 3.92 3.44 18.90  1  0    4    4
#Maserati Bora     15.0   8 301.0 335 3.54 3.57 14.60  0  1    5    8


Hope this helps,

Rui Barradas

?s 11:43 de 28/01/2019, Knut Krueger via R-help escreveu: