I have a data.frame that looks like this.
dat1=data.frame(time=c(1,2,1,2,1,2,1,2), team=c("A","A","A","A","B","B","C","C"), name=c("LT","LT","CH","CH","CH","CH","AT","AT"))
time team name
1 A LT
2 A LT
1 A CH
2 A CH
1 B CH
2 B CH
1 C AT
2 C AT
I would like to say to dplyr, please, group_by "team" and filter the rows of each team that contains the name "LT". If a team does not contain the name "LT", then filter in the name "CH."
I would like my data.frame to look like this.
time team name
1 A LT
2 A LT
1 B CH
2 B CH
Any help is highly appreciated