-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new tables Co-authored-by: benoit <benoit.falquet@roche.com>
- Loading branch information
Showing
11 changed files
with
499 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
#' EGT01 Table 1 (Default) ECG Assessments and Change from Baseline by Visit Table 1 | ||
#' | ||
#' The `EGT01` table 1 summarizes several electrocardiogram parameters and their evolution throughout the study. | ||
#' | ||
#' @inheritParams gen_args | ||
#' @param summaryvars (`vector of string`) the variables to be analyzed. For this table, `AVAL` and `CHG` by default. | ||
#' @param summaryvars_lbls (`vector of string`) the label of the variables to be analyzed. | ||
#' @param visitvar (`string`) typically one of `"AVISIT"` (Default) or `"ATPTN"` depending on the type of time point to | ||
#' be displayed | ||
#' | ||
#' @details | ||
#' * The `Analysis Value` column, displays the number of patients, the mean, standard deviation, median and range of | ||
#' the analysis value for each visit. | ||
#' * The `Change from Baseline` column, displays the number of patient and the mean, standard deviation, | ||
#' median and range of changes relative to the baseline. | ||
#' * Remove zero-count rows unless overridden with `prune_0 = FALSE`. | ||
#' * Split columns by arm, typically `ACTARM`. | ||
#' * Does not include a total column by default. | ||
#' * Sorted based on factor level; first by `PARAM` labels in alphabetic order then by chronological time point given | ||
#' by `AVISIT`. Re-level to customize order | ||
#' | ||
#' @importFrom dplyr filter | ||
#' | ||
#' @export | ||
#' | ||
#' @examples | ||
#' library(dm) | ||
#' | ||
#' db <- syn_test_data() %>% | ||
#' preprocess_data("egt01_1") | ||
#' | ||
#' egt01_1(db) | ||
#' egt01_1(db, summaryvars_lbls = c("Value at Visit", "Change from Baseline")) | ||
#' | ||
egt01_1 <- function(adam_db, | ||
armvar = .study$armvar, | ||
summaryvars = .study$evo_vars, | ||
summaryvars_lbls = var_labels_for(adam_db$adeg, summaryvars), | ||
visitvar = "AVISIT", # or ATPTN | ||
prune_0 = TRUE, | ||
deco = std_deco("EGT01"), | ||
.study = list( | ||
armvar = "ACTARM", | ||
evo_vars = c("AVAL", "CHG") | ||
)) { | ||
|
||
lbl_AVISIT <- var_labels_for(adam_db$adeg, visitvar) | ||
lbl_PARAM <- var_labels_for(adam_db$adeg, "PARAM") | ||
|
||
lyt <- egt01_1_lyt( | ||
armvar = armvar, | ||
summaryvars = summaryvars, | ||
summaryvars_lbls = summaryvars_lbls, | ||
visitvar = visitvar, | ||
lbl_AVISIT = lbl_AVISIT, | ||
lbl_PARAM = lbl_PARAM, | ||
deco = deco | ||
) | ||
|
||
tbl <- build_table( | ||
lyt, | ||
df = adam_db$adeg | ||
) | ||
|
||
if (prune_0) tbl <- tbl %>% prune_table() | ||
|
||
tbl | ||
|
||
} | ||
|
||
#' EGT01 Layout 1 (Default) | ||
#' | ||
#' @describeIn egt01_1 | ||
#' | ||
#' @inheritParams gen_args | ||
#' | ||
#' @param summaryvars (`vector of string`) the variables to be analyzed. For this table, `AVAL` and `CHG` by default. | ||
#' @param summaryvars_lbls (`vector of string`) the label of the variables to be analyzed. | ||
#' @param visitvar (`string`) typically one of `"AVISIT"` (Default) or `"ATPTN"` depending on the type of time point to | ||
#' be displayed. | ||
#' @param lbl_AVISIT (`string`) label of the `visitvar` variable. | ||
#' @param lbl_PARAM (`string`) label of the `PARAM` variable. | ||
#' | ||
#' @return | ||
#' @export | ||
egt01_1_lyt <- function(armvar = .study$armvar, | ||
summaryvars = .study$evo_vars, | ||
summaryvars_lbls = .study$evo_vars_lbls, | ||
visitvar = .study$visitvar, | ||
lbl_AVISIT = "", | ||
lbl_PARAM = "", | ||
deco = std_deco("EGT01"), | ||
.study = list( | ||
armvar = "ACTARM", | ||
evo_vars = c("AVAL", "CHG"), | ||
evo_vars_lbls = c("Analysis \nValue", "Change from \nBaseline"), | ||
visitvar = "AVISIT" | ||
) | ||
) { | ||
|
||
|
||
# TODE solve the problem of the overall column | ||
# remove change from baseline in BASELINE | ||
|
||
basic_table_deco(deco) %>% | ||
split_cols_by(armvar) %>% | ||
split_rows_by( | ||
"PARAM", | ||
split_fun = drop_split_levels, | ||
label_pos = "hidden", | ||
split_label = paste(lbl_PARAM) | ||
) %>% | ||
split_rows_by( | ||
visitvar, | ||
split_fun = drop_split_levels, | ||
label_pos = "hidden", | ||
split_label = lbl_AVISIT | ||
) %>% | ||
split_cols_by_multivar( | ||
vars = summaryvars, | ||
varlabels = summaryvars_lbls, | ||
nested = TRUE | ||
) %>% | ||
summarize_colvars() %>% | ||
append_topleft(paste(lbl_PARAM)) %>% | ||
append_topleft(c(paste(" ", lbl_AVISIT), " ")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
#' VST01 Table 1 (Default) Vital Sign Results and change from Baseline By Visit Table 1 | ||
#' | ||
#' The `VST01` table provides an overview of the Vital Sign values and its change from baseline of each respective arm | ||
#' over the course of the trial. | ||
#' | ||
#' @inheritParams gen_args | ||
#' @param summaryvars (`vector of string`) the variables to be analyzed. For this table, `AVAL` and `CHG` by default. | ||
#' @param summaryvars_lbls (`vector of string`) the label of the variables to be analyzed. | ||
#' @param visitvar (`string`) typically one of `"AVISIT"` (Default) or `"ATPTN"` depending on the type of time point to | ||
#' be displayed | ||
#' | ||
#' @details | ||
#' * The `Analysis Value` column, displays the number of patients, the mean, standard deviation, median and range of | ||
#' the analysis value for each visit. | ||
#' * The `Change from Baseline` column, displays the number of patient and the mean, standard deviation, | ||
#' median and range of changes relative to the baseline. | ||
#' * Remove zero-count rows unless overridden with `prune_0 = FALSE`. | ||
#' * Split columns by arm, typically `ACTARM`. | ||
#' * Does not include a total column by default. | ||
#' * Sorted based on factor level; first by `PARAM` labels in alphabetic order then by chronological time point given | ||
#' by `AVISIT`. Re-level to customize order | ||
#' | ||
#' @importFrom dplyr filter | ||
#' | ||
#' @export | ||
#' | ||
#' @examples | ||
#' library(dm) | ||
#' | ||
#' db <- syn_test_data() %>% | ||
#' preprocess_data("vst01_1") | ||
#' | ||
#' vst01_1(db) | ||
#' vst01_1(db, summaryvars_lbls = c("Value at Visit", "Change from Baseline")) | ||
#' | ||
vst01_1 <- function(adam_db, | ||
armvar = .study$armvar, | ||
summaryvars = .study$evo_vars, | ||
summaryvars_lbls = var_labels_for(adam_db$advs, summaryvars), | ||
visitvar = "AVISIT", # or ATPTN | ||
prune_0 = TRUE, | ||
deco = std_deco("VST01"), | ||
.study = list( | ||
armvar = "ACTARM", | ||
evo_vars = c("AVAL", "CHG") | ||
)) { | ||
|
||
lbl_AVISIT <- var_labels_for(adam_db$advs, visitvar) | ||
lbl_PARAM <- var_labels_for(adam_db$advs, "PARAM") | ||
|
||
lyt <- vst01_1_lyt( | ||
armvar = armvar, | ||
summaryvars = summaryvars, | ||
summaryvars_lbls = summaryvars_lbls, | ||
visitvar = visitvar, | ||
lbl_AVISIT = lbl_AVISIT, | ||
lbl_PARAM = lbl_PARAM, | ||
deco = deco | ||
) | ||
|
||
tbl <- build_table( | ||
lyt, | ||
df = adam_db$advs, | ||
alt_counts_df = adam_db$adsl | ||
) | ||
|
||
if (prune_0) tbl <- tbl %>% trim_rows() | ||
|
||
tbl | ||
} | ||
|
||
#' LBT01 Layout 1 (Default) | ||
#' | ||
#' @describeIn vst01_1 | ||
#' | ||
#' @inheritParams gen_args | ||
#' | ||
#' @param summaryvars (`vector of string`) the variables to be analyzed. For this table, `AVAL` and `CHG` by default. | ||
#' @param summaryvars_lbls (`vector of string`) the label of the variables to be analyzed. | ||
#' @param visitvar (`string`) typically one of `"AVISIT"` (Default) or `"ATPTN"` depending on the type of time point to | ||
#' be displayed. | ||
#' @param lbl_AVISIT (`string`) label of the `visitvar` variable. | ||
#' @param lbl_PARAM (`string`) label of the `PARAM` variable. | ||
#' | ||
#' @return | ||
#' @export | ||
vst01_1_lyt <- function(armvar = .study$armvar, | ||
summaryvars = .study$evo_vars, | ||
summaryvars_lbls = .study$evo_vars_lbls, | ||
visitvar = .study$visitvar, | ||
lbl_AVISIT = "", | ||
lbl_PARAM = "", | ||
deco = std_deco("EGT01"), | ||
.study = list( | ||
armvar = "ACTARM", | ||
evo_vars = c("AVAL", "CHG"), | ||
evo_vars_lbls = c("Analysis \nValue", "Change from \nBaseline"), | ||
visitvar = "AVISIT" | ||
) | ||
) { | ||
|
||
|
||
# TODE solve the problem of the overall column | ||
# remove change from baseline in BASELINE | ||
# problem with the column count | ||
|
||
basic_table_deco(deco) %>% | ||
split_cols_by(armvar) %>% | ||
split_rows_by( | ||
"PARAM", | ||
split_fun = drop_split_levels, | ||
label_pos = "hidden", | ||
split_label = paste(lbl_PARAM) | ||
) %>% | ||
split_rows_by( | ||
visitvar, | ||
split_fun = drop_split_levels, | ||
label_pos = "hidden", | ||
split_label = lbl_AVISIT | ||
) %>% | ||
split_cols_by_multivar( | ||
vars = summaryvars, | ||
varlabels = summaryvars_lbls, | ||
nested = TRUE | ||
) %>% | ||
summarize_colvars() %>% | ||
append_topleft(paste(lbl_PARAM)) %>% | ||
append_topleft(paste(" ", lbl_AVISIT)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.