mingsu dat1 %>% dplyr::group_by(x2) %>% dplyr::filter(length(unique(x1)) == length(unique(.$x1))) %>% dplyr::ungroup()