So, this is a follow-up to the previous question that I asked. After two years, I am now facing a similar problem, but I want to name the list elements according to level combinations.
Let's say that we are working with the mtcars
dataset and that we do this:
mtcars %>%
group_split(gear, carb)
The resulting list's elements will not be named. However, I would like the first element to be named '3_1' since it contains cars that have gear 3 and carb 1, the second one should be named '3_2' and so on.
The solution from the previous question works only if you have one grouping level. If we have 2 like here (gear and carb), it doesn't seem to work because names()` must be the same length as x.
I have tried using paste
and unite
to force the group keys into a single column, but it doesn't seem to work. Any help would be appreciated.