[R] "not all duplicated" question

Vesco Miloushev vesco.miloushev at gmail.com
Sat Jul 13 22:12:05 CEST 2013


Hi,

I want to select elements which have duplicates by are not all duplicated.

Here is what I mean. Suppose I have a two column matrix with columns
"Country" and "Pet"


Country, Pet
------------------
France, Dog
France, Cat
France, Dog
Canada, Cat
Canada, Cat
Japan, Dog
Japan, Cat
Italy, Cat

I want to extract all the entries that are duplicated in column
"Country" but not ALL duplicated in column "Pet".

In this case I want

Country, Pet
------------------
France, Dog
France, Cat
France, Dog
Japan, Dog
Japan, Cat

Notice that I keep France, because not all are duplicated. If there
was no entry "France, Cat" then it all of the entries with "France"
would be eliminated.

Thanks for your help.



More information about the R-help mailing list