I have a dataset like this:
group services
1 75
1 105
1 110
2 110
2 110
2 110
I want to create a flag where if any of the group service values fall below 100, it is flagged 0. If they are all above 100, it is flagged 1. Output would be:
group services flag
1 75 0
1 105 0
1 110 0
2 110 1
2 110 1
2 110 1
The dataset is thousands of groups long, so I'm not sure how to do this. I tried using dplyr as
dataset%>%
group_by_(group)%>%
mutate(flag:= services>=100)
I tried searching, but couldn't find an answer as to how to get the flag to apply to a whole group for a large dataset with lots of groups.