Skip to content

Commit

Permalink
Check in changes (2nd time) - DEVR-3489-fix-bugs-for-generating-title
Browse files Browse the repository at this point in the history
  • Loading branch information
lm3388 committed Nov 4, 2024
1 parent 34536ae commit 710c7cd
Show file tree
Hide file tree
Showing 17 changed files with 82 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ Suggests:
tidyr
Config/testthat/edition: 3
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
10 changes: 10 additions & 0 deletions R/tlf_ae_exp_adj.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#' format_ae_exp_adj() |>
#' tlf_ae_exp_adj(
#' source = "Source: [CDISCpilot: adam-adsl; adae]",
#' analysis = "ae_exp_adj",
#' path_outdata = tempfile(fileext = ".Rdata"),
#' path_outtable = tempfile(fileext = ".rtf")
#' )
Expand All @@ -59,6 +60,15 @@ tlf_ae_exp_adj <- function(outdata,
n_row <- nrow(tbl)
n_col <- ncol(tbl)

# Check if the parameter analysis contains the correct analysis that should exist in "outdata$meta$analysis"
analysis_name <- names(outdata$meta$analysis)
if (!(analysis %in% analysis_name)) {
stop(
"Please provide a valid analysis that matches with what being defined in 'outdata$meta$analysis'",
call. = FALSE
)
}

parameters <- unlist(strsplit(outdata$parameter, ";"))

# Title
Expand Down
10 changes: 10 additions & 0 deletions R/tlf_ae_listing.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#' tlf_ae_listing(
#' footnotes = "footnote1",
#' source = "Source: [CDISCpilot: adam-adsl; adae]",
#' analysis = "ae_listing",
#' path_outdata = tempfile(fileext = ".Rdata"),
#' path_outtable = tempfile(fileext = ".rtf")
#' )
Expand All @@ -54,6 +55,15 @@ tlf_ae_listing <- function(outdata,
path_outtable = NULL) {
res <- outdata$tbl

# Check if the parameter analysis contains the correct analysis that should exist in "outdata$meta$analysis"
analysis_name <- names(outdata$meta$analysis)
if (!(analysis %in% analysis_name)) {
stop(
"Please provide a valid analysis that matches with what being defined in 'outdata$meta$analysis'",
call. = FALSE
)
}

mapping <- collect_adam_mapping(outdata$meta, analysis)
var_name <- eval(mapping$var_name)
subline <- eval(mapping$subline)
Expand Down
10 changes: 10 additions & 0 deletions R/tlf_ae_specific.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#' format_ae_specific() |>
#' tlf_ae_specific(
#' source = "Source: [CDISCpilot: adam-adsl; adae]",
#' analysis = "ae_specific",
#' meddra_version = "24.0",
#' path_outdata = tempfile(fileext = ".Rdata"),
#' path_outtable = tempfile(fileext = ".rtf")
Expand Down Expand Up @@ -94,6 +95,15 @@ tlf_ae_specific <- function(outdata,
)
}

# Check if the parameter analysis contains the correct analysis that should exist in "outdata$meta$analysis"
analysis_name <- names(outdata$meta$analysis)
if (!(analysis %in% analysis_name)) {
stop(
"Please provide a valid analysis that matches with what being defined in 'outdata$meta$analysis'",
call. = FALSE
)
}

# Define title
if ("analysis" %in% title | "observation" %in% title | "population" %in% title) {
title_key <- title
Expand Down
10 changes: 10 additions & 0 deletions R/tlf_ae_specific_subgroup.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#' tlf_ae_specific_subgroup(
#' meddra_version = "24.0",
#' source = "Source: [CDISCpilot: adam-adsl; adae]",
#' analysis = "ae_specific",
#' path_outtable = tempfile(fileext = ".rtf")
#' )
tlf_ae_specific_subgroup <- function(
Expand Down Expand Up @@ -91,6 +92,15 @@ tlf_ae_specific_subgroup <- function(
)
}

# Check if the parameter analysis contains the correct analysis that should exist in "outdata$meta$analysis"
analysis_name <- names(outdata$meta$analysis)
if (!(analysis %in% analysis_name)) {
stop(
"Please provide a valid analysis that matches with what being defined in 'outdata$meta$analysis'",
call. = FALSE
)
}

# Define title
if (is.null(title)) {
title <- collect_title(outdata$meta,
Expand Down
10 changes: 10 additions & 0 deletions R/tlf_ae_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#' format_ae_summary() |>
#' tlf_ae_summary(
#' source = "Source: [CDISCpilot: adam-adsl; adae]",
#' analysis = "ae_summary",
#' path_outdata = tempfile(fileext = ".Rdata"),
#' path_outtable = tempfile(fileext = ".rtf")
#' )
Expand All @@ -57,6 +58,15 @@ tlf_ae_summary <- function(outdata,
n_row <- nrow(tbl)
n_col <- ncol(tbl)

# Check if the parameter analysis contains the correct analysis that should exist in "outdata$meta$analysis"
analysis_name <- names(outdata$meta$analysis)
if (!(analysis %in% analysis_name)) {
stop(
"Please provide a valid analysis that matches with what being defined in 'outdata$meta$analysis'",
call. = FALSE
)
}

parameters <- unlist(strsplit(outdata$parameter, ";"))

# Title
Expand Down
4 changes: 4 additions & 0 deletions man/tlf_ae_exp_adj.Rd

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

4 changes: 4 additions & 0 deletions man/tlf_ae_listing.Rd

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

4 changes: 4 additions & 0 deletions man/tlf_ae_specific.Rd

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

4 changes: 4 additions & 0 deletions man/tlf_ae_specific_subgroup.Rd

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

4 changes: 4 additions & 0 deletions man/tlf_ae_summary.Rd

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

2 changes: 2 additions & 0 deletions tests/testthat/test-independent-testing-empty_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ generate_analysis_or_empty <- function(meta, outdata) {
) |>
tlf_ae_specific(
source = "Source: [CDISCpilot: adam-adsl; adae]",
analysis = "ae_specific",
meddra_version = "24.0",
path_outdata = path_rdata,
path_outtable = path_rtf
Expand Down Expand Up @@ -74,6 +75,7 @@ test_that("RTF output: empty table or analysis table.", {
) |>
tlf_ae_specific(
source = "Source: [CDISCpilot: adam-adsl; adae]",
analysis = "ae_specific",
meddra_version = "24.0",
path_outdata = path_rdata,
path_outtable = path_rtf
Expand Down
2 changes: 1 addition & 1 deletion vignettes/ae-listing.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ tbl |> tlf_ae_listing(
footnotes = footnote,
orientation = "portrait",
source = "Source: [CDISCpilot: adam-adsl; adae]",
analysis = "ae_listing",
analysis = "ae_listing", # Provide analysis type defined in meta$analysis
path_outtable = "rtf/ae0listing0ser0wk12.rtf",
path_outdata = NULL
)
Expand Down
2 changes: 1 addition & 1 deletion vignettes/ae-specific-subgroup.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ outdata |>
tlf_ae_specific_subgroup(
meddra_version = "24.0",
source = "Source: [CDISCpilot: adam-adsl; adae]",
analysis = "ae_specific",
analysis = "ae_specific", # Provide analysis type defined in meta$analysis
path_outtable = "rtf/ae0specific0sub0gender1.rtf"
)
```
Expand Down
6 changes: 3 additions & 3 deletions vignettes/ae-specific.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ outdata |>
tlf_ae_specific(
meddra_version = "24.0",
source = "Source: [CDISCpilot: adam-adsl; adae]",
analysis = "ae_specific",
analysis = "ae_specific", # Provide analysis type defined in meta$analysis
path_outtable = "rtf/ae0specific1.rtf"
)
```
Expand All @@ -273,7 +273,7 @@ outdata |>
tlf_ae_specific(
meddra_version = "24.0",
source = "Source: [CDISCpilot: adam-adsl; adae]",
analysis = "ae_specific",
analysis = "ae_specific", # Provide analysis type defined in meta$analysis
col_rel_width = c(6, rep(1, 8)),
text_font_size = 8,
orientation = "landscape",
Expand All @@ -293,7 +293,7 @@ outdata |>
tlf_ae_specific(
meddra_version = "24.0",
source = "Source: [CDISCpilot: adam-adsl; adae]",
analysis = "ae_specific",
analysis = "ae_specific", # Provide analysis type defined in meta$analysis
path_outtable = "rtf/mock_ae0specific1.rtf"
)
```
Expand Down
6 changes: 3 additions & 3 deletions vignettes/ae-summary.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ outdata |>
format_ae_summary() |>
tlf_ae_summary(
source = "Source: [CDISCpilot: adam-adsl; adae]",
analysis = "ae_summary",
analysis = "ae_summary", # Provide analysis type defined in meta$analysis
path_outtable = "rtf/ae0summary1.rtf"
)
```
Expand All @@ -203,7 +203,7 @@ outdata |>
format_ae_summary() |>
tlf_ae_summary(
source = "Source: [CDISCpilot: adam-adsl; adae]",
analysis = "ae_summary",
analysis = "ae_summary", # Provide analysis type defined in meta$analysis
col_rel_width = c(6, rep(1, 8)),
text_font_size = 8,
orientation = "landscape",
Expand All @@ -230,7 +230,7 @@ outdata |>
format_ae_summary(mock = TRUE) |>
tlf_ae_summary(
source = "Source: [CDISCpilot: adam-adsl; adae]",
analysis = "ae_summary",
analysis = "ae_summary", # Provide analysis type defined in meta$analysis
path_outtable = "rtf/mock_ae0summary1.rtf"
)
```
Expand Down
1 change: 1 addition & 0 deletions vignettes/metalite-ae.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ meta_ae_example() |> # Example AE data created using metalite
format_ae_summary() |>
tlf_ae_summary(
source = "Source: [CDISCpilot: adam-adsl; adae]", # Define data source
analysis = "ae_specific", # Provide analysis type defined in meta$analysis
path_outtable = "ae0summary.rtf" # Define output
)
```
Expand Down

0 comments on commit 710c7cd

Please sign in to comment.