I have a dataframe with three colmuns; name of data point, group number assigned to that data point and species (data is animal related, and data points belong to one of two species).
Any given row looks like this
Name | Group Number | Species
Data Point A | 3 | 1
I would like to split groups only if that group contains above 90% of only one species, e.g if group 3 is 10 rows long and has 9 rows belonging only to either species 1 or species 2, then it satisfies my requirements and should be split.
I have looked into using the split
function as well as the filter
functions from dplyr but I can't seem to figure out how to get r to split groups with this percentage-based requirement. Any help would be useful, thank you!