A lot of helpful solutions that pretty much all work. Thanks, everyone!

 
_____
Kevin Parent, Ph.D
Korea Maritime University

________________________________
 From: Rolf Turner <rolf.turner@xtra.co.nz>
To: Jim Lemon <jim@bitwrit.com.au> 

ject.org> 
Sent: Thursday, August 8, 2013 6:26 PM
Subject: Re: [R] Extracting only multiple occurrences


On 08/08/13 20:27, Jim Lemon wrote:
> On 08/08/2013 04:23 PM, Kevin Parent wrote:
>> Well that almost works, and I didn't know about duplicated() so 
>> thanks for that. However, it only gives me the duplicated values. I 
>> need the original ones too. So the result I want is: 
>> [g,g,m,m,s,s,t,t,u,u,u,v,v,x,x,y,y,y]. What duplicated() gives me is 
>> [g,m,s,t,u,u,v,x,y,y]
>>
>>
> Hi Kevin,
> How about:
>
> x[x %in% duplicated(x)]

Uh, I think you mean

     x[x %in% x[duplicated(x)]]

Another idear:

     tx <- table(x)
     tx <- tx[tx>1]
     rep(names(tx),tx)

Well, that's three lines as opposed to one, so not as good.  But it 
perhaps demonstrates
a useful tool to add to one's kit.

     cheers,

     Rolf
	[[alternative HTML version deleted]]

