View source: R/in_group_indices.R
| add_group_sub_indices | R Documentation | 
Group a data frame and add in-group indices as a column.
add_group_sub_indices( .data, ..., groupingVars, orderColumn, arrangeTerms = NULL, env = parent.frame() )
| .data | data.frame | 
| ... | force later arguments to bind by name. | 
| groupingVars | character vector of column names to group by. | 
| orderColumn | character name of column to add in-group order marks to. | 
| arrangeTerms | character vector of column expressions to arrange by. | 
| env | environment to work in. | 
.data with in group order indices added (no ties).
groupingVars = c("cyl", "gear")
datasets::mtcars %.>%
  # dplyr doesn't currently export tibble::rownames_to_column()
  mutate_se(., "CarName" := "rownames(.)" ) %.>%
  select_se(., c('CarName', 'cyl', 'gear', 'hp', 'wt')) %.>%
  add_group_indices(., groupingVars = groupingVars,
                    indexColumn = 'groupID') %.>%
  add_group_sub_indices(., groupingVars = groupingVars,
                       arrangeTerms = c('desc(hp)', 'wt'),
                       orderColumn = 'orderInGroup') %.>%
  arrange_se(., c('groupID', 'orderInGroup'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.