Skip to content

Add Table 14.1.3 generation script aligned with gtsummary-based TLF style - #81

Open
bms63 with Copilot wants to merge 10 commits into
mainfrom
copilot/update-table-code-style
Open

Add Table 14.1.3 generation script aligned with gtsummary-based TLF style#81
bms63 with Copilot wants to merge 10 commits into
mainfrom
copilot/update-table-code-style

Conversation

Copilot AI commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

This PR adds an R implementation for Table 14-1.03 (Summary of Number of Subjects By Site) based on ADSL, matching the style and structure established in PR #67. It reproduces treatment-wise ITT/Eff/Com counts by pooled/site IDs, including a total row and formatted PDF output.

  • Table program implementation

    • Added code/tables/t_14_1_3.r to generate Table 14.1.3 from adsl.json.
    • Derives per-treatment counts for ITT, Eff, and Com using ITTFL, EFFFL, and COMP24FL.
    • Produces grouped rows by SITEGR1 (Pooled ID) and SITEID, with an overall TOTAL row.
    • Preserves missing/dirty site values for display instead of filtering them out.
  • Output artifacts and formatting

    • Writes ARD output as data/tables/ard/t_14_1_3.rds using gtsummary + gather_ard().
    • Renders PDF table via gt + docorator with protocol/population headers and note/footer text consistent with the target table style.
    • Keeps pooled ID suppression as a display-only transformation (not in stored ARD data).
    • Applies bold styling to column headers/spanners and keeps label capitalization as ID.
  • Repository path/config alignment

    • Extended .Rprofile path list with:
      • table_output = data/tables/pdf
      • table_ard = data/tables/ard
    • Added/updated .gitignore scaffolding under data/tables/, data/tables/ard/, and data/tables/pdf/ for generated outputs.
  • Documentation updates

    • Updated AGENTS.md to explicitly require:
      • gtsummary + gather_ard() for ARD generation in TLF scripts.
      • Display of missing/dirty analysis values in tables rather than silently dropping them.
t_14_1_3_ard <- adsl_total %>%
  mutate(
    across(
      c(itt, eff, com),
      ~ if_else(is.na(.x), NA_character_, if_else(.x == 1L, "Y", "N")),
      .names = "{.col}_flag"
    )
  ) %>%
  tbl_summary(
    by = trt01p,
    statistic = all_dichotomous() ~ "{n}",
    include = c(itt_flag, eff_flag, com_flag),
    value = list(c("itt_flag", "eff_flag", "com_flag") ~ "Y")
  ) %>%
  gather_ard()

@bms63

bms63 commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Created by Copilot

image

Original from CDISC Pilot

image

@bms63

bms63 commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Co-authored-by: bms63 <10111024+bms63@users.noreply.github.com>

Copilot AI commented Apr 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Resolved and pushed. I merged origin/main into this branch and fixed all merge conflicts in .Rprofile and table output .gitignore files in commit f92266e.

Copilot AI requested a review from bms63 April 17, 2026 20:36
@DmitryMK

Copy link
Copy Markdown
Collaborator

@bms63 As discussed we are going to use #88, but I had a quick look at this PR.
I'm switching to farming profession as I spent many hours doing this table and GH Copilot got the correct results right away.

Yet there are few things to consider:

  1. It did not use gtsummary, so we should put it somewhere in the instructions.
  2. It assumed that adding _ard prefix to a data frame, makes it a data frame. We should add an instruction to use gather_ard for the ARD file.
  3. Minor style issues, like using "ID" in the labels instead of "Id". Did not use bold style for headers.
  4. It dropped missing values/dirty data. E.g., if filtered missing sites. I think sites cannot be missing in ADSL, yet we might want to add a general instruction, that instead of filtering dirty data, we want to show it in the tables.

@bms63

bms63 commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

@copilot can you adjust this code to use the gtsummary R package also please add instructions found into the AGENTS.md file for It assumed that adding _ard prefix to a data frame, makes it a data frame. We should add an instruction to use gather_ard for the ARD file.
Minor style issues, like using "ID" in the labels instead of "Id". Did not use bold style for headers.
It dropped missing values/dirty data. E.g., if filtered missing sites. I think sites cannot be missing in ADSL, yet we might want to add a general instruction, that instead of filtering dirty data, we want to show it in the tables.

Copilot AI commented Apr 27, 2026

Copy link
Copy Markdown
Contributor Author

@copilot can you adjust this code to use the gtsummary R package also please add instructions found into the AGENTS.md file for It assumed that adding _ard prefix to a data frame, makes it a data fr...

Implemented in commits 65e0856, 3fed804, and 994655b.

I updated code/tables/t_14_1_3.r to use gtsummary + gather_ard() for ARD output, kept missing/dirty site records in the table instead of filtering them out, and applied header bold styling while keeping Pooled ID/Site ID labels. I also updated AGENTS.md with explicit guidance to use gather_ard() (not _ard naming alone) and to display missing/dirty table records instead of silently dropping them.

Updated table screenshot:
Updated Table 14.1.3

Copilot AI changed the title Add Table 14.1.3 generation script aligned with existing TLF style Add Table 14.1.3 generation script aligned with gtsummary-based TLF style Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants