Skip to content

Commit 01fa61f

Browse files
committed
ready for review
1 parent dff6493 commit 01fa61f

File tree

5 files changed

+85
-2
lines changed

5 files changed

+85
-2
lines changed

NEWS.md

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
`make_table_09_gtsum`, `make_table_32_gtsum`.
1616
* Added option to include risk difference columns in tables using the `split_cols_by_arm` function via the `risk_diff` argument.
1717
* Added risk difference functionality into relevant table-generating functions via the `risk_diff` argument.
18+
* Added new function for creating standard FDA tables using additional packages:
19+
`make_table_33_gtsum`.
1820

1921
### Miscellaneous
2022
* Initialized the package.

quarto/index-templates.qmd

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ title: Template Library Index
5353

5454
- [FDA Table 35 -- Patients With Adverse Events by System Organ Class, Safety Population, Pooled Analysis (or Trial X)](table-templates/template-table_35.qmd)
5555

56-
- [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)
56+
- [FDA Table 36 -- Patients With Adverse Events by System Organ Class and Preferred Term, Safety Population, Pooled Analysis (or Trial X)](table-templates/template-table_36.qmd)
5757

58-
- [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)
58+
- [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)
5959

6060

6161
------------------------------------------------------------------------

quarto/table-templates/template-table_33.qmd

+44
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,49 @@ Required variables:
7070
| `annotations` | (named `list` of `character`) List of annotations to add to the table. Valid annotation types are `title`, `subtitles`, `main_footer`, and `prov_footer.` Each name-value pair should use the annotation type as name and the desired string as value. | `NULL` |
7171
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+
7272

73+
Source code for this function is available [here](https://github.com/pharmaverse/falcon/blob/main/R/fda-table_33.R).
74+
75+
## gtsummary Table
76+
77+
```{r tbl_gtsum, message=FALSE, warning=FALSE}
78+
# Load Libraries & Data
79+
library(falcon)
80+
81+
adsl <- random.cdisc.data::cadsl
82+
advs <- random.cdisc.data::cadvs
83+
advs$AVAL <- advs$AVAL - 100
84+
85+
# Output table
86+
tbl <- make_table_33_gtsum(advs = advs)
87+
tbl
88+
```
89+
90+
## gtsummary Table Setup
91+
92+
```{r tbl_gtsum, eval=FALSE, echo=TRUE}
93+
```
94+
95+
## Function Details: `make_table_33_gtsum`
96+
97+
### `make_table_33_gtsum()`
98+
99+
------------------------------------------------------------------------
100+
101+
Required variables:
102+
103+
- **`advs`**: `USUBJID`, `AVISITN`, `PARAMCD`, `AVAL`, `AVALU`, and the variables specified by `arm_var` and `saffl_var`.
104+
105+
+---------------+--------------------------------------------------------------------------------------------------------------------+----------------------+
106+
| Argument | Description | Default |
107+
+:==============+:===================================================================================================================+:=====================+
108+
| `advs` | (`data.frame`) Dataset (typically ADVS) required to build table. | *No default* |
109+
+---------------+--------------------------------------------------------------------------------------------------------------------+----------------------+
110+
| `arm_var` | (`character`) Arm variable used to split table into columns. | `"ARM"` |
111+
+---------------+--------------------------------------------------------------------------------------------------------------------+----------------------+
112+
| `saffl_var` | (`character`) Flag variable used to indicate inclusion in safety population. | `"SAFFL"` |
113+
+---------------+--------------------------------------------------------------------------------------------------------------------+----------------------+
114+
| `lbl_overall` | (`character`) If specified, an overall column will be added to the table with the given value as the column label. | `"Total Population"` |
115+
+---------------+--------------------------------------------------------------------------------------------------------------------+----------------------+
116+
73117
Source code for this function is available [here](https://github.com/pharmaverse/falcon/blob/main/R/fda-table_33.R).
74118
:::

tests/testthat/_snaps/fda-table_33.md

+22
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,25 @@
5454
SBP <90 85 (63.4%) 84 (62.7%) 90 (68.2%) -0.7 (-12.3 - 10.8)
5555
DBP <60 133 (99.3%) 134 (100%) 132 (100%) 0.7 (-0.7 - 2.2)
5656

57+
# Table 33 (gtsum) generation works with default values
58+
59+
Code
60+
res
61+
Output
62+
# A tibble: 2 x 8
63+
variable var_type var_label row_type label stat_1 stat_2 stat_3
64+
<chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
65+
1 SBP90 dichotomous SBP &lt;90 label SBP &lt;90 85 (63.4%) 84 (62~ 90 (6~
66+
2 DBP60 dichotomous DBP &lt;60 label DBP &lt;60 133 (99.3%) 134 (1~ 132 (~
67+
68+
# Table 33 (gtsum) generation works with custom values
69+
70+
Code
71+
res
72+
Output
73+
# A tibble: 2 x 9
74+
variable var_type var_label row_type label stat_1 stat_2 stat_3 stat_0
75+
<chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
76+
1 SBP90 dichotomous SBP &lt;90 label SBP &lt;~ 85 (6~ 84 (6~ 90 (6~ 259 (~
77+
2 DBP60 dichotomous DBP &lt;60 label DBP &lt;~ 133 (~ 134 (~ 132 (~ 399 (~
78+

tests/testthat/test-fda-table_33.R

+15
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,18 @@ test_that("Table 33 generation works with risk difference column", {
5050
res <- expect_silent(result)
5151
expect_snapshot(res)
5252
})
53+
54+
test_that("Table 33 (gtsum) generation works with default values", {
55+
result <- suppressWarnings(make_table_33_gtsum(advs = advs) %>% gt::extract_body())
56+
res <- expect_silent(result)
57+
expect_snapshot(res)
58+
})
59+
60+
test_that("Table 33 (gtsum) generation works with custom values", {
61+
result <- suppressWarnings(
62+
make_table_33_gtsum(advs = advs, lbl_overall = "Total Population") %>% gt::extract_body()
63+
)
64+
65+
res <- expect_silent(result)
66+
expect_snapshot(res)
67+
})

0 commit comments

Comments
 (0)