I have a large dataframe
with speciesID
's and Individual ID
's.
For my dataset I need to remove the SpeciesID
's when the occurrence of the unique combination of SpeciesID
and IndID
are less than 4 times.
For example I have the dataset:
SpeciesID IndID
99 13-001
99 13-001
99 14-002
99 14-002
99 14-002
100 14-005
100 14-005
100 14-005
100 14-006
100 14-007
100 14-007
100 14-008
100 14-009
500 16-001
500 16-001
500 16-002
500 16-002
500 16-002
500 16-003
500 16-003
500 16-004
500 16-004
500 16-005
500 16-006
500 16-006
500 16-007
Seeing this dataset I want to remove the rows where the unique combination of SpeciesID
and IndID
occur less than 5 times:
In this case I want to remove:
99 13-001
99 13-001
99 14-002
99 14-002
99 14-002
Because the unique combination of:
99 13-001
99 14-002
only appears 2 times.