Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

195 new table table 36 #208

Merged
merged 13 commits into from
Mar 11, 2024
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export(make_table_32_gtsum)
export(make_table_33)
export(make_table_34)
export(make_table_35)
export(make_table_36)
export(make_table_38)
export(split_cols_by_arm)
import(Tplyr)
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Added new functions for creating standard FDA tables: `make_table_02`, `make_table_03`, `make_table_04`, `make_table_05`,
`make_table_06`, `make_table_07`, `make_table_08`, `make_table_09`, `make_table_10`, `make_table_11`, `make_table_12`,
`make_table_13`, `make_table_14`, `make_table_15`, `make_table_16`, `make_table_17`, `make_table_18`, `make_table_20`,
`make_table_21`, `make_table_22`, `make_table_32`, `make_table_33`, `make_table_34`, `make_table_35`.
`make_table_21`, `make_table_22`, `make_table_32`, `make_table_33`, `make_table_34`, `make_table_35`, `make_table_36`.
* Added new functions for creating standard FDA figures: `make_fig_01`, `make_fig_02`, `make_fig_14`.
* Added helper functions used within table functions:
* `basic_table_annot` for adding basic table annotations (titles, footnotes, column counts).
Expand Down
73 changes: 73 additions & 0 deletions R/fda-table_36.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#' Table 36. Patients With Adverse Events by System Organ Class and Preferred Term, Safety
#' Population, Pooled Analysis (or Trial X)
#'
#' @details
#' * `adae` must contain the variables specified by `id_var`, `arm_var`, `saffl_var`, `soc_var`,
#' and `pref_var`.
#' * If specified, `alt_counts_df` must contain the variables specified by `arm_var`, `id_var`, and `saffl_var`.
#' * Columns are split by arm. Overall population column is excluded by default (see `lbl_overall` argument).
#' * Numbers in table represent the absolute numbers of patients and fraction of `N`.
#' * All-zero rows are removed by default (see `prune_0` argument).
#'
#' @inheritParams argument_convention
#'
#' @return
#' * `make_table_36` returns an `rtables` table object.
#'
#' @examples
#' adsl <- random.cdisc.data::cadsl
#' adae <- random.cdisc.data::cadae
#'
#' tbl <- make_table_35(adae = adae, alt_counts_df = adsl)
#' tbl
#'
#' @export
make_table_36 <- function(
adae,
alt_counts_df = NULL,
show_colcounts = TRUE,
id_var = "USUBJID",
arm_var = "ARM",
saffl_var = "SAFFL",
soc_var = "AESOC",
pref_var = "AEDECOD",
lbl_soc_var = formatters::var_labels(adae, fill = TRUE)[soc_var],
lbl_overall = NULL,
risk_diff = NULL,
prune_0 = FALSE,
annotations = NULL) {
adae <- adae %>%
filter(.data[[saffl_var]] == "Y") %>%
df_explicit_na()

alt_counts_df <- alt_counts_df_preproc(
alt_counts_df,
id_var,
arm_var,
saffl_var
)

lyt <- basic_table_annot(show_colcounts, annotations) %>%
split_cols_by_arm(arm_var, lbl_overall, risk_diff) %>%
split_rows_by(
soc_var,
label_pos = "topleft",
split_label = lbl_soc_var
) %>%
summarize_num_patients(
var = id_var,
riskdiff = !is.null(risk_diff),
.stats = "unique",
.labels = c(unique = NULL)
) %>%
count_occurrences(
vars = pref_var,
drop = FALSE,
riskdiff = !is.null(risk_diff)
)

tbl <- build_table(lyt, df = adae, alt_counts_df = alt_counts_df)
if (prune_0) tbl <- prune_table(tbl)

tbl
}
1 change: 1 addition & 0 deletions _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ website:
- quarto/table-templates/template-table_33.qmd
- quarto/table-templates/template-table_34.qmd
- quarto/table-templates/template-table_35.qmd
- quarto/table-templates/template-table_36.qmd
- quarto/figure-templates/template-fig_01.qmd
- quarto/figure-templates/template-fig_02.qmd
- quarto/figure-templates/template-fig_14.qmd
Expand Down
17 changes: 17 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,29 @@ ADEX
ADSL
ADSUB
ADVS
AE
ARD
Abinaya
Assuied
CDISC
CDISC's
FMQ
Huan
Hypotension
Knizia
Korbinian
Koujin
Pharmaverse
Postbaseline
Pre
Rua
TLGs
Yichen
Yogasekaram
Yoshito
Yuye
datetime
de
ncol
pharmaverse
pre
92 changes: 92 additions & 0 deletions man/make_table_36.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions quarto/index-templates.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ title: Template Library Index

- [FDA Table 38 -- Patients With Adverse Events by System Organ Class, FDA Medical Query (Broad) and Preferred Term, Safety Population, Pooled Analysis (or Trial X)](table-templates/template-table_38.qmd)

- [FDA Table 36 -- Patients With Adverse Events1 by System Organ Class and Preferred Term, Safety Population, Pooled Analysis (or Trial X)](table-templates/template-table_35.qmd)


------------------------------------------------------------------------

Expand Down
Loading
Loading