Created
November 25, 2025 14:45
-
-
Save elipousson/1dd60d8a4b8fb9505ff9bfdd530fc54e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tt_group <- function(x, ..., by = NULL, hide_group = TRUE) { | |
| x <- dplyr::group_by(x, {{ by }}) | |
| vars <- dplyr::group_vars(x) | |
| # Error if more than a single group is supplied | |
| stopifnot(rlang::has_length(vars, 1)) | |
| x <- dplyr::arrange( | |
| dplyr::ungroup(x), | |
| .data[[vars]] | |
| ) | |
| if (hide_group) { | |
| df <- dplyr::select( | |
| x, | |
| !tidyselect::any_of(vars) | |
| ) | |
| } | |
| tinytable::group_tt( | |
| tinytable::tt(df, ...), | |
| i = x[[vars]] | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment