Given a table like:
id value
1 1 a
2 2 a
3 2 b
4 2 c
5 3 c
I would like to filter for:
a) the ids that o
Try
a)
df %>% group_by(id) %>% filter(all(value == "a"))
b)
df %>% group_by(id) %>% filter(all(c("a", "b") %in% value))
Here is an alternative approach that can be used both for a) and b)
df %>% group_by(id) %>% arrange(value) %>% summarize(value=paste(value,collapse="")) %>% filter(grepl("ab",value))
Result:
id value
(dbl) (chr)
1 2 abc
Hope this helps