Skip to content
Back to formatted view

Raw Message

Message-ID: <10fa4e79-fa37-77cd-1077-6b9fc93f88ed@sapo.pt>
Date: 2019-01-28T11:51:37Z
From: Rui Barradas
Subject: duplicates including first occurrence
In-Reply-To: <476e6b4b-d2d4-0a0a-b1d3-7833a82bfcf1@krueger-family.de>

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:
> Ho to all
> 
> i get the? results
> 
> mtcars[duplicated(mtcars$wt,fromLast=TRUE),]
> 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
> 
> 
> mtcars[duplicated(mtcars$wt),]
> 
> Merc 280????? 19.2?? 6 167.6 123 3.92 3.44 18.3? 1? 0??? 4??? 4
> Merc 280C???? 17.8?? 6 167.6 123 3.92 3.44 18.9? 1? 0??? 4??? 4
> Maserati Bora 15.0?? 8 301.0 335 3.54 3.57 14.6? 0? 1??? 5??? 8
> 
> 
> The first occurrence is missing - is there any possibility to get
> 
> Hornet Sportabout 18.7?? 8 360.0 175 3.15 3.44 17.02? 0? 0??? 3??? 2
> 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
> Duster 360??? 14.3?? 8? 360 245 3.21 3.57 15.84? 0? 0??? 3??? 4
> Maserati Bora 15.0?? 8? 301 335 3.54 3.57 14.60? 0? 1??? 5??? 8
> 
> 
> Kind regards Knut
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.