Skip to content

Commit 25bc93f

Browse files
committed
address comments from PR review
1 parent 9d9a055 commit 25bc93f

File tree

4 files changed

+20
-31
lines changed

4 files changed

+20
-31
lines changed

R/fda-table_02.R

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
#' * Flag variables (i.e. `XXXFL`) are expected to have two levels: `"Y"` (true) and `"N"` (false). Missing values in
99
#' flag variables are treated as `"N"`.
1010
#'
11-
#' @inheritParams tbl_make_table_02
11+
#' @inheritParams make_table_02
1212
#' @inheritParams argument_convention
1313
#'
1414
#' @return A `gtsummary` table and, if `return_ard = TRUE`, an ARD.
1515
#' If `return_ard = TRUE`, they will be returned as a list with named elements `table` and `ard`.
1616
#'
17-
#' @seealso [`tbl_make_table_02`]
17+
#' @seealso [`make_table_02`]
1818
#'
1919
#' @examples
2020
#' library(dplyr)
@@ -32,7 +32,6 @@
3232
#'
3333
#' @export
3434
make_table_02 <- function(df,
35-
denominator = NULL,
3635
return_ard = TRUE,
3736
arm_var = "ARM",
3837
saffl_var = "SAFFL",
@@ -112,12 +111,11 @@ make_table_02 <- function(df,
112111
#' AGE >= 65 & AGE < 75 ~ ">=65 to <75",
113112
#' AGE >= 75 ~ ">=75"
114113
#' )))
115-
#' tbl_rtables <- cardinal:::make_table_05_rtables(df = adsl)
114+
#' tbl_rtables <- make_table_02_rtables(df = adsl)
116115
#' tbl_rtables
117116
#' @rdname make_table_02
118117
#' @export
119118
make_table_02_rtables <- function(df,
120-
alt_counts_df = NULL,
121119
show_colcounts = TRUE,
122120
arm_var = "ARM",
123121
saffl_var = "SAFFL",
@@ -134,8 +132,6 @@ make_table_02_rtables <- function(df,
134132
filter(.data[[saffl_var]] == "Y") %>%
135133
df_explicit_na()
136134

137-
alt_counts_df <- alt_counts_df_preproc(alt_counts_df, id_var, arm_var, saffl_var)
138-
139135
lyt <- basic_table_annot(show_colcounts, annotations) %>%
140136
split_cols_by_arm(arm_var, lbl_overall) %>%
141137
analyze_vars(
@@ -148,7 +144,7 @@ make_table_02_rtables <- function(df,
148144
) %>%
149145
append_topleft("Characteristic")
150146

151-
tbl <- build_table(lyt, df = df, alt_counts_df = alt_counts_df)
147+
tbl <- build_table(lyt, df = df)
152148
if (prune_0) tbl <- prune_table(tbl)
153149

154150
tbl

man/make_table_02.Rd

Lines changed: 2 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

quarto/getting_started.qmd

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ The `cardinal` package requires several packages available on CRAN.
1717
To use the `cardinal` package, ensure you have these necessary package dependencies installed by running the following code:
1818

1919
```{r, echo=TRUE, eval=FALSE}
20+
if (!require("gtsummary")) install.packages("gtsummary")
21+
if (!require("cards")) install.packages("cards")
22+
if (!require("cardx")) install.packages("cardx")
2023
if (!require("formatters")) install.packages("formatters")
2124
if (!require("rtables")) install.packages("rtables")
2225
if (!require("rlistings")) install.packages("rlistings")
@@ -63,7 +66,7 @@ Each template provided is associated with a function available within the `cardi
6366

6467
![](./assets/images/getting-started/gs-pan3.png){fig-align="center" width="90%"}
6568

66-
- **Function Details**: This tab includes details on the table-generating function used for this template. Table functions use the naming convention `make_table_XX()` where `XX` is the table number taken from the FDA Standard Safety Table and Figures document (preceded by a 0 if the number is a single digit). Any required variables for the input datasets are listed along with a description of all function arguments. This information is mirrored by the function's help page accessible within R (i.e. `?make_table_XX`).
69+
- **Function Details**: This tab includes details on the table-generating function used for this template. Table functions use the naming convention `make_table_XX()` where `XX` is the table number taken from the FDA Standard Safety Table and Figures document (preceded by a 0 if the number is a single digit). Any required variables for the input datasets are listed along with a description of all function arguments. This information is mirrored by the function's help page accessible within R (i.e. `?make_table_XX`). By default, all table generating functions use the {gtsummary} package - though we do support rtables functionality. To specify the use of which table engine is being used, engine specific functions can be called (`make_table_02_rtables`, for example).
6770

6871
![](./assets/images/getting-started/gs-pan4.png){fig-align="center" width="90%"}
6972

@@ -90,8 +93,7 @@ adsl <- random.cdisc.data::cadsl %>%
9093
AGE >= 65 ~ ">=65",
9194
AGE >= 65 & AGE < 75 ~ ">=65 to <75",
9295
AGE >= 75 ~ ">=75"
93-
)) %>% formatters::with_label("Age Group, years")) %>%
94-
formatters::var_relabel(AGE = "Age, years")
96+
)))
9597
9698
# Create table
9799
tbl <- make_table_02(df = adsl)
@@ -115,18 +117,15 @@ anl <- left_join(adsl, advs, by = "USUBJID") %>% tern::df_explicit_na()
115117
116118
tbl <- make_table_02(
117119
df = anl,
118-
vars = c("SEX", "AGE", "RACE", "COUNTRY", "AVAL"),
119-
lbl_vars = c("Sex", "Age, years", "Race", "Country of Participation", "Baseline Temperature (C)"),
120-
lbl_overall = "Total\nPopulation",
121-
na_rm = TRUE
120+
vars = c("SEX", "AGE", "RACE", "COUNTRY", "AVAL")
122121
)
123-
tbl
122+
tbl$tbl
124123
```
125124

126125
Note that the `prune_0` argument can be set to specify whether all-zero rows should be included in a table. For example, see that the demographics table below includes rows for `OTHER` and `UNKNOWN` for which all values are zero, whereas these two rows were excluded from the previous tables (`prune_0` defaults to `TRUE` in `make_table_02()`).
127126

128127
```{r, echo=TRUE}
129-
make_table_02(df = anl, vars = "RACE", prune_0 = FALSE)
128+
make_table_02_rtables(df = anl, vars = "RACE", prune_0 = FALSE)
130129
```
131130

132131
### Feature Requests

quarto/table-templates/template-table_02.qmd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ adsl <- adsl %>%
3535
# Output Table
3636
make_table_02(
3737
df = adsl,
38-
vars = c("SEX", "AGE", "AGEGR1", "RACE", "ETHNIC", "COUNTRY", "AVAL"),
38+
vars = c("SEX", "AGE", "AGEGR1", "RACE", "ETHNIC", "COUNTRY"),
3939
return_ard = FALSE
4040
)
4141
```
@@ -59,7 +59,7 @@ Required variables:
5959
- **`denominator`** (if specified): `USUBJID` and the variables specified by `arm_var` and `saffl_var`.
6060

6161
| | | |
62-
|----|----|----|
62+
|------------------------|------------------------|------------------------|
6363
| **Argument** | **Description** | **Default** |
6464
| `df` | (`data.frame`) Dataset (typically ADSL) required to build table. | *No default* |
6565
| `return_ard` | (`flag`) Whether an ARD should be returned. | `TRUE` |
@@ -98,7 +98,7 @@ adsl <- adsl %>%
9898
# Create Table & ARD
9999
result <- make_table_02(
100100
df = adsl,
101-
vars = c("SEX", "AGE", "AGEGR1", "RACE", "ETHNIC", "COUNTRY", "AVAL")
101+
vars = c("SEX", "AGE", "AGEGR1", "RACE", "ETHNIC", "COUNTRY")
102102
)
103103
104104
# Output ARD
@@ -109,7 +109,7 @@ result$ard
109109

110110
```{r tbl1-print, echo=FALSE}
111111
options(width = 9999)
112-
print(result$ard, columns = "all", n = Inf)
112+
print(result$ard, columns = "all")
113113
```
114114

115115
## rtables Table
@@ -143,7 +143,7 @@ advs <- advs %>%
143143
anl <- left_join(adsl, advs, by = "USUBJID")
144144
145145
# Output Table
146-
make_table_02(
146+
make_table_02_rtables(
147147
df = anl,
148148
vars = c("SEX", "AGE", "AGEGR1", "RACE", "ETHNIC", "COUNTRY", "AVAL"),
149149
lbl_vars = c(
@@ -172,7 +172,7 @@ Required variables:
172172
- **`alt_counts_df`** (if specified): `USUBJID` and the variables specified by `arm_var` and `saffl_var`.
173173

174174
| **Argument** | **Description** | **Default** |
175-
|:---|:---|:---|
175+
|:-----------------------|:-----------------------|:-----------------------|
176176
| `df` | (`data.frame`) Dataset (typically ADSL) required to build table. | *No default* |
177177
| `alt_counts_df` | (`character`) Alternative dataset used only to calculate column counts. | `NULL` |
178178
| `show_colcounts` | (`flag`) Whether column counts should be printed. | `TRUE` |

0 commit comments

Comments
 (0)