dplyr - group_by using colnumber?

Hello,
I recently opened a data frame containing log names for variables.
I wonder if It's possible to use the group_by but selecting the columns/variables by the variable order.
I mean, Can I use var1 and var2 as:

data %>% group_by(1,2)  %>% count()

If var1 es the first and var2 is the second variable?
I know It's strange, but the data I have is rare.
I already tried the code above and It failed.
Thanks for your work and time.

This seems to work.

group_by(across(c(1,2)))
1 Like

Thanks. It worked flawless.
It's great when you don't want to lose info renaming a variable, but you have troubles handling long names.
Thanks again, FJCC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.