[R] Extracting only multiple occurrences

David Winsemius dwinsemius at comcast.net
Thu Aug 8 08:08:07 CEST 2013


On Aug 7, 2013, at 11:03 PM, David Winsemius wrote:

> 
> On Aug 7, 2013, at 10:37 PM, Kevin Parent wrote:
> 
>> Hoping someone here can help me with this small problem.
>> set.seed(2013)
>> 
>> x<-sort(c(letters,letters[sample(26,10,1)]))
>> 
>> This gives a vector of 36 letters with some muliples (in this case, g,m,s,t,u,v,x,y). Now what I need is to get rid of the ones that only occur once and keep the multiples. I need the opposite of the unique() function. I expect this should be pretty easy but I can't see it. Anyone know a solution? Thanks in advance!
>> 
>> 
> ?duplicated
> 
> x[ duplicated(x) ]
> 

Also this may be of interest:

cran.r-project.org/doc/contrib/Short-refcard.pdf‎

... but I was suprised to find that both duplicated and rle are absent from Short's refcards.


-- 
David Winsemius
Alameda, CA, USA



More information about the R-help mailing list