I have this data.
group name 1 A 1 A 1 A 1 B 1 C 2 A 2 B 3 A 3 B 3 C 3 D I would like to filter the group with a standard. For example, I would like to filter the group inside {A, B, C}.
Group 1 would be filtered because {A, B, C} (unique combination of Group 1) is in {A, B, C}.
Group 2 would be filtered because {A, B} is in {A, B, C}
However, Group 3 would not be filtered because {A, B, C, D} is not the subset of {A, B, C}.
How should I approach this issue? Additionally, I have more standards (i.e., {A, B, C} and {A, C} ...).
structure(list(group = c(1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 3), name = c("A", "A", "A", "B", "C", "A", "B", "A", "B", "C", "D")), row.names= c(NA, -11L), class = c("tbl_df", "tbl", "data.frame"))
df1 %>% group_by(group) %>% filter(all(unique(name) %in% c("A", "B", "C")))or its oppositedf1 %>% group_by(group) %>% filter(!all(unique(name) %in% c("A", "B", "C")))