dplyr has a group_indices()
function that you can use like this:
df %>%
mutate(label = group_indices(., u, v)) %>%
group_by(label) ...
More Related Contents:
- Relative frequencies / proportions with dplyr
- Finding percentage in a sub-group using group_by and summarise
- Count non-NA values by group [duplicate]
- dplyr issues when using group_by(multiple variables)
- dplyr – groupby on multiple columns using variable names
- Use variable names in functions of dplyr
- Create new variables with mutate_at while keeping the original ones
- Make a group_indices based on several columns
- Using spread with duplicate identifiers for rows
- filter for complete cases in data.frame using dplyr (case-wise deletion)
- dplyr filter with condition on multiple columns
- dplyr – using column names as function arguments
- Fill missing dates by group
- dplyr – filter by group size
- dplyr::group_by_ with character string input of several variable names
- How to parametrize function calls in dplyr 0.7?
- How to filter rows based on difference in dates between rows in R?
- How to do range grouping on a column using dplyr?
- Performing dplyr mutate on subset of columns
- Arranging rows in custom order using dplyr
- R: How to filter/subset a sequence of dates
- Get first and last values per group – dplyr group_by with last() and first()
- How does one stop using rowwise in dplyr?
- grouped operations that result in length not equal to 1 or length of group in dplyr
- Create sequential counter that restarts on a condition within panel data groups [duplicate]
- dplyr summarize with subtotals
- How to find difference between values in two rows in an R dataframe using dplyr
- use rollapply and zoo to calculate rolling average of a column of variables
- Unlisting columns by groups
- dplyr – Group by and select TOP x %