pharmaverse / pharmaverse/tern
Fix leaves level for `count_occurrences` and `summarize_num_patients`
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 106
- Forks
- 34
- Avg merge
- 8d 9h
- Merged PRs (30d)
- 6
Description
ref: https://github.com/insightsengineering/rtables/issues/663
code:
basic_table() %>%
split_cols_by("ACTARM") %>%
split_rows_by("AEBODSYS", child_labels = "visible") %>%
summarize_num_patients("USUBJID", # Q: do we need this to be a label row (i.e. content row)?
.stats = c("unique", "nonunique"),
.labels = c("Total number of patients with at least one adverse event", "Total number of events")) %>%
count_occurrences("AEDECOD", .indent_mods = -1L) %>% # Q: do we always need this collapse?
build_table(ex_adae, alt_counts_df = ex_adsl)
A: Drug X B: Placebo C: Combination
—————————————————————————————————————————————————————————————————————————————————————————————————————
cl A.1
Total number of patients with at least one adverse event 78 (58.2%) 75 (56.0%) 89 (67.4%)
Total number of events 132 130 160
dcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%)
dcd A.1.1.1.2 48 (35.8%) 48 (35.8%) 50 (37.9%)
cl B.1
Total number of patients with at least one adverse event 47 (35.1%) 49 (36.6%) 43 (32.6%)
Total number of events 56 60 62
dcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 43 (32.6%)
cl B.2
Total number of patients with at least one adverse event 79 (59.0%) 74 (55.2%) 85 (64.4%)
Total number of events 129 138 143
dcd B.2.1.2.1 49 (36.6%) 44 (32.8%) 52 (39.4%)
dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%)
cl C.1
Total number of patients with at least one adverse event 43 (32.1%) 46 (34.3%) 43 (32.6%)
Total number of events 55 63 64
dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%)
cl C.2
Total number of patients with at least one adverse event 35 (26.1%) 48 (35.8%) 55 (41.7%)
Total number of events 48 53 65
dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%)
cl D.1
Total number of patients with at least one adverse event 79 (59.0%) 67 (50.0%) 80 (60.6%)
Total number of events 127 106 135
dcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%)
dcd D.1.1.4.2 48 (35.8%) 42 (31.3%) 50 (37.9%)
cl D.2
Total number of patients with at least one adverse event 47 (35.1%) 58 (43.3%) 57 (43.2%)
Total number of events 62 72 74
dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%)
Can I ask @clarkliming if dcd * are always NOT indented vs Total number of*?
Note on the problem: pruning out Totals makes dcd * collapse to -1L indentation because the parent node is lost, therefore being on same level of cl *
Proposal: remove summarize and add the totals as options for the count (therefore getting only one leave level with only analyzes).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with count_occurrences, summarize_num_patients, and build_table, then read the linked rtables issue 663 for context. Reproduce the example with ex_adae and ex_adsl, focusing on how pruning totals changes the leaf indentation. Done means the proposed handling of totals preserves the intended hierarchy and clearly resolves whether the dcd rows should remain unindented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100