I'm currently working in R with a data table containing two columns: id and type. The type value can be female, male, or both. There are instances where ID is repeated with differing values of Type. I'd like to delete obs. with Type==Both but only if obs. for the same ID are present that have a type == female and type==male.
This is my current table:
id type
1 both
1 female
1 male
2 both
2 female
3 both
3 male
3 female
4 both
5 male
6 female
I'd like the table to resemble the following:
id type
1 female
1 male
2 both
2 female
3 male
3 female
4 both
5 male
6 female
*obs with type==both are only deleted if the same id also contains type==female and type==male