mardi 23 mai 2017

ifelse with condition on rows

I want to group the data by ID and slice the first row, based on condition.

I have the following dataset:

head(data) 

    ID Cond1 
     A   10
     A   10
     B   20
     B   30

Now, I want to slice the rows based on condition:

  • If value in Cond1 is unique for both rows, keep them;
  • If value in Cond1 is duplicate, keep top row.

Any ideas?

Aucun commentaire:

Enregistrer un commentaire