I have an issue about removing the groups that contain certain strings in its rows for example if includes .
. I would like to achive this without breaking the pipeline. I mean without using any join
function.
The example data
vals <- c("good","bad",'ugly',"good","bad.","ugly")
gr <- gl(2,3)
vals gr
1 good 1
2 bad 1
3 ugly 1
4 good 2
5 bad. 2
6 ugly 2
df <- data.frame(vals,gr)
I tried
library(dplyr)
df%>%
filter(!grepl("\\.",vals))
which removes only the row that match the condition. But I want to remove entire gr 2
.
vals gr
1 good 1
2 bad 1
3 ugly 1
4 good 2
5 ugly 2