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

591 Add tm_t_exposure title/subtitle #607

Merged
merged 8 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Updated `tm_a_mmrm` column name when no treatment is selected from "all obs" to "All Patients".
* Added a subtitle to `tm_g_ci` with visit name.
* Added subtitles and footnotes to `tm_a_mmrm` tables and plots.
* Added a title and parameter category subtitle to `tm_t_exposure`, cleaned up labels.

### Bug fixes

Expand Down
12 changes: 9 additions & 3 deletions R/tm_t_exposure.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ template_exposure <- function(parentname,
parsed_basic_table_args <- teal.widgets::parse_basic_table_args(
teal.widgets::resolve_basic_table_args(
user_table = basic_table_args,
module_table = teal.widgets::basic_table_args(main_footer = paste0("* Patient time is the sum of ", paramcd_label))
module_table = teal.widgets::basic_table_args(
main_footer = paste0("* Patient Time is the sum of ", paramcd_label)
)
)
)

Expand Down Expand Up @@ -122,9 +124,10 @@ template_exposure <- function(parentname,
summarize_patients_exposure_in_cols(
var = aval_var, col_split = TRUE,
.labels = c(
n_patients = "Patient time*",
n_patients = "Number of Patients",
sum_exposure = paste("Sum of", paramcd, sprintf("(%s)", avalu_var))
)
),
custom_label = "Total Number of Patients and Patient Time*"
),
env = list(
aval_var = aval_var,
Expand Down Expand Up @@ -577,6 +580,9 @@ srv_t_exposure <- function(id,
input_paramcd_label <- as.character(paramcd_map[paramcd_map[1] == input_paramcd, 2])
}

basic_table_args$title <- "Duration of Exposure Table"
basic_table_args$subtitles <- paste("Parameter Category:", anl_m$filter_info$parcat[[1]]$selected[[1]])

my_calls <- template_exposure(
parentname = "ANL_ADSL",
dataname = "ANL",
Expand Down
77 changes: 39 additions & 38 deletions tests/testthat/test-tm_t_exposure.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ testthat::test_that("template_exposure generates correct expressions with defaul
}),
layout_prep = quote(split_fun <- drop_split_levels),
layout = quote(
lyt <- rtables::basic_table(main_footer = "* Patient time is the sum of TDURD") %>%
lyt <- rtables::basic_table(main_footer = "* Patient Time is the sum of TDURD") %>%
rtables::split_cols_by("SEX") %>%
rtables::add_colcounts() %>%
summarize_patients_exposure_in_cols(
var = "AVAL",
col_split = TRUE,
.labels = c(
n_patients = "Patient time*",
sum_exposure = paste("Sum of", "TDURD", sprintf("(%s)", "Days"))
)
var = "AVAL", col_split = TRUE,
.labels = c(n_patients = "Number of Patients", sum_exposure = paste(
"Sum of",
"TDURD", sprintf("(%s)", "Days")
)), custom_label = "Total Number of Patients and Patient Time*"
) %>%
rtables::split_rows_by(
"RACE",
label_pos = "topleft",
split_fun = split_fun,
rtables::split_rows_by("RACE",
label_pos = "topleft", split_fun = split_fun,
split_label = formatters::var_labels(adex["RACE"], fill = TRUE),
nested = FALSE
) %>%
summarize_patients_exposure_in_cols(var = "AVAL", col_split = FALSE)
summarize_patients_exposure_in_cols(
var = "AVAL",
col_split = FALSE
)
),
table = quote({
result <- rtables::build_table(lyt = lyt, df = anl, alt_counts_df = adsl)
Expand Down Expand Up @@ -68,25 +68,26 @@ testthat::test_that("template_exposure generates correct expressions with custom
}),
layout_prep = quote(split_fun <- drop_split_levels),
layout = quote(
lyt <- rtables::basic_table(main_footer = "* Patient time is the sum of myTDURD") %>%
lyt <- rtables::basic_table(main_footer = "* Patient Time is the sum of myTDURD") %>%
rtables::split_cols_by("SEX") %>%
rtables::add_colcounts() %>%
summarize_patients_exposure_in_cols(
var = "myAVAL",
col_split = TRUE,
.labels = c(
n_patients = "Patient time*",
sum_exposure = paste("Sum of", "myTDURD", sprintf("(%s)", "Days"))
)
var = "myAVAL", col_split = TRUE,
.labels = c(n_patients = "Number of Patients", sum_exposure = paste(
"Sum of",
"myTDURD", sprintf("(%s)", "Days")
)), custom_label = "Total Number of Patients and Patient Time*"
) %>%
rtables::split_rows_by(
"myRACE",
label_pos = "topleft",
split_fun = split_fun,
split_label = formatters::var_labels(myadex["myRACE"], fill = TRUE),
nested = FALSE
rtables::split_rows_by("myRACE",
label_pos = "topleft", split_fun = split_fun,
split_label = formatters::var_labels(myadex["myRACE"],
fill = TRUE
), nested = FALSE
) %>%
summarize_patients_exposure_in_cols(var = "myAVAL", col_split = FALSE)
summarize_patients_exposure_in_cols(
var = "myAVAL",
col_split = FALSE
)
),
table = quote({
result <- rtables::build_table(lyt = lyt, df = anl, alt_counts_df = myadsl)
Expand Down Expand Up @@ -118,25 +119,25 @@ testthat::test_that("template_exposure generates correct expressions with paramc
}),
layout_prep = quote(split_fun <- drop_split_levels),
layout = quote(
lyt <- rtables::basic_table(main_footer = "* Patient time is the sum of Total Duration (Days)") %>%
lyt <- rtables::basic_table(main_footer = "* Patient Time is the sum of Total Duration (Days)") %>%
rtables::split_cols_by("SEX") %>%
rtables::add_colcounts() %>%
summarize_patients_exposure_in_cols(
var = "AVAL",
col_split = TRUE,
.labels = c(
n_patients = "Patient time*",
sum_exposure = paste("Sum of", "TDURD", sprintf("(%s)", "Days"))
)
var = "AVAL", col_split = TRUE,
.labels = c(n_patients = "Number of Patients", sum_exposure = paste(
"Sum of",
"TDURD", sprintf("(%s)", "Days")
)), custom_label = "Total Number of Patients and Patient Time*"
) %>%
rtables::split_rows_by(
"RACE",
label_pos = "topleft",
split_fun = split_fun,
rtables::split_rows_by("RACE",
label_pos = "topleft", split_fun = split_fun,
split_label = formatters::var_labels(adex["RACE"], fill = TRUE),
nested = FALSE
) %>%
summarize_patients_exposure_in_cols(var = "AVAL", col_split = FALSE)
summarize_patients_exposure_in_cols(
var = "AVAL",
col_split = FALSE
)
),
table = quote({
result <- rtables::build_table(lyt = lyt, df = anl, alt_counts_df = adsl)
Expand Down