Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 202012

Dropping rows by condition

$
0
0

I'm working on the Brazilian local elections database and now I need to drop rows that contain more than one candidate ELECTED by Municipality. My data looks like:

>df
Candidate     Municipality      Situation 
Rose               A            ELECTED
Mark               A            NON-ELECTED
Linda              A            ELECTED
Jhon               A            NON-ELECTED
James              B            ELECTED
Phillip            B            NON-ELECTED
Bruce              B            NON-ELECTED

In the case illustrated above, the elected candidate in municipality A had his mandate revoked, therefore, we had another election.

So, I'm looking for a routine that automatically drops any case like this in my data. The output I desire in this case is like:

>df
    Candidate     Municipality      Situation 
    James              B            ELECTED
    Phillip            B            NON-ELECTED
    Bruce              B            NON-ELECTED

Regards,


Viewing all articles
Browse latest Browse all 202012

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>