modified sort_ard_hierarchical function#550
Conversation
|
✅ All contributors have signed the CLA |
|
I have read the CLA Document and I hereby sign the CLA |
|
@rikoprogrammer thanks for the PR. Can you address the CI/CD failures, please? The contributing guide often guides us to the resolution. https://github.com/insightsengineering/cards/blob/main/.github/CONTRIBUTING.md Thanks! |
| Sys.getenv() | ||
| library(cards) | ||
| library(gtsummary) |
There was a problem hiding this comment.
we need to add this to .gitignore
There was a problem hiding this comment.
oh my goodness! can you add, please? I am surprised it wasn't already there! 😱
| #' sums, otherwise `p` is used. If neither `n` nor `p` are present in `x` for the variable, an error will occur. | ||
| #' | ||
| #' Defaults to `everything() ~ "descending"`. | ||
| #' @param sort_col \cr |
There was a problem hiding this comment.
after the argument name, we put the expected type of input. maybe that is causing your latex issue
There was a problem hiding this comment.
okay,thanks for the hint.
Code Review1. Committed
|
Signed-off-by: Daniel Sjoberg <danield.sjoberg@gmail.com>
|
Thanks for the comments @ddsjoberg |
…to ard_sort merged main into ard_sort
Signed-off-by: Eric Odongo <65663507+rikoprogrammer@users.noreply.github.com>
|
@ddsjoberg Any updates on this? Thanks |
Hi @rikoprogrammer , thanks for the updates in response to the review.
|
…to ard_sort Merge into ard_sort
…to ard_sort merge branch into ard_sort.
|
Thanks for clearing up the failing checks @rikoprogrammer . Can you explain how this works when there are 1. No devtools::load_all("/Users/sjobergd/Documents/GitHub/cards")
#> ℹ Loading cards
# there is no by variable, I think this should error, right?
ard_stack_hierarchical_count(
ADAE,
variables = c(AESOC, AEDECOD),
# by = TRTA,
denominator = ADSL
) |>
sort_ard_hierarchical(sort_level = "CARDIAC DISORDERS")
#> {cards} data frame: 265 x 11
#> group1 group1_level variable variable_level stat_name stat_label stat
#> 1 <NA> AESOC CARDIAC … n n 91
#> 2 AESOC CARDIAC … AEDECOD SINUS BR… n n 24
#> 3 AESOC CARDIAC … AEDECOD MYOCARDI… n n 16
#> 4 AESOC CARDIAC … AEDECOD ATRIAL F… n n 7
#> 5 AESOC CARDIAC … AEDECOD ATRIOVEN… n n 6
#> 6 AESOC CARDIAC … AEDECOD SUPRAVEN… n n 5
#> 7 AESOC CARDIAC … AEDECOD VENTRICU… n n 5
#> 8 AESOC CARDIAC … AEDECOD BRADYCAR… n n 4
#> 9 AESOC CARDIAC … AEDECOD ATRIAL F… n n 3
#> 10 AESOC CARDIAC … AEDECOD BUNDLE B… n n 3
#> ℹ 255 more rows
#> ℹ Use `print(n = ...)` to see more rows
#> ℹ 4 more variables: context, fmt_fun, warning, errordevtools::load_all("/Users/sjobergd/Documents/GitHub/cards")
#> ℹ Loading cards
# there are two by variables, but it's unclear how the sorting should be done...
ard_stack_hierarchical_count(
ADAE,
variables = c(AESOC, AEDECOD),
by = c(TRTA, SEX),
denominator = ADSL
) |>
sort_ard_hierarchical(sort_level = "F")
#> Error in `sort_ard_hierarchical()`:
#> ! `sort_level` must be one of "Placebo", "Xanomeline High Dose", or
#> "Xanomeline Low Dose", not "F".Created on 2026-06-30 with reprex v2.1.1 |
|
Can you also add an entry to (When it's ready for another look, can you please ping me here? Otherwise, I won't be notified that the updates have been made.) |
…or if by statement is missing and more than two variables are specified in the by variables. Updated the NEWS.md file in regards to the new argument added

Propose to add the ability to sort an ard based on a particular treatment column
NEWS.md. (Feature Request: sort_ard_hierarchical #548, @)There was a need to sort hierarchical tables based on one of the treatment columns eg Placebo. The current function sorts by getting the sum across all the treatment columns. So I proposed if we can get an extra argument in the function that can be used for this purpose.
Closes #548
Pre-review Checklist (if item does not apply, mark is as complete)
usethis::pr_merge_main(): yesdevtools::test_coverage():completeReviewer Checklist (if item does not apply, mark is as complete)
pkgdown::build_site(). Check the R console for errors, and review the rendered website.devtools::test_coverage()When the branch is ready to be merged:
NEWS.mdwith the changes from this pull request under the heading "# cards (development version)". If there is an issue associated with the pull request, reference it in parentheses at the end update (seeNEWS.mdfor examples).Optional Reverse Dependency Checks:
Install
checkedwithpak::pak("Genentech/checked")orpak::pak("checked")