After reading the comments, particularly those about how groups would get merged, I realise that what I was asking did not make sense. This is the result that I actually want to achieve in my programme:
I have a tibble dataframe that looks as follows (although my actual dataframe is longer):
Group Person
<dbl> <chr>
1 1 Person 1.1
2 2 Person 1.2
3 2 Person 1.2
4 3 Person 2.1
5 4 Person 2.1
6 4 Person 3.1
7 5 Person 1.2
8 5 Person 4.1
9 6 Person 1.2
10 6 Person 4.2
I want the tibble to be split by Group. However, I have a group 2 that just has person 1.2 in it, but as person 1.2 is in group 5 with person 4.1 and in group 6 with person 4.2, I would like to delete group 2. Hence, if there is a group with only one type of person, and that person is in a group with another person, then they group where they are by themselves should be deleted.
Then the dataframe would look like this:
Group Person
<dbl> <chr>
1 1 Person 1.1
4 3 Person 2.1
5 4 Person 2.1
6 4 Person 3.1
7 5 Person 1.2
8 5 Person 4.1
9 6 Person 1.2
10 6 Person 4.2
Reproducible data for example dataframe above:
structure(list(Group = c(1, 2, 2, 3, 4, 4, 5, 5, 6, 6), Person =
c("Person 1.1",
"Person 1.2", "Person 1.2", "Person 2.1", "Person 2.1", "Person 3.1",
"Person 1 .2", "Person 4.1", "Person 1.2", "Person 4.2")), spec =
structure(list(
cols = list(Group = structure(list(), class = c("collector_double",
"collector")), Person = structure(list(), class =
c("collector_character",
"collector"))), default = structure(list(), class =
c("collector_guess",
"collector")), skip = 1), class = "col_spec"), row.names = c(NA,
-10L), class = c("tbl_df", "tbl", "data.frame"))