Skip to content

Commit

Permalink
Add tests, fix spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
edelarua committed Jul 7, 2023
1 parent 5960db8 commit 0fb3ec3
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 6 deletions.
2 changes: 1 addition & 1 deletion R/count_patients_with_flags.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ NULL
#' @param flag_labels (`character`)\cr vector of labels to use for flag variables.
#'
#' @note If `flag_labels` is not specified, variables labels will be extracted from `df`. If variables are not
#' labelled, variable names will be used instead. Alternatively, a named `vector` can be supplied to
#' labeled, variable names will be used instead. Alternatively, a named `vector` can be supplied to
#' `flag_variables` such that within each name-value pair the name corresponds to the variable name and the value is
#' the label to use for this variable.
#'
Expand Down
2 changes: 1 addition & 1 deletion man/count_patients_with_flags.Rd

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

52 changes: 52 additions & 0 deletions tests/testthat/_snaps/count_patients_with_flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,55 @@
Grade 3-5 AE 47 (68.1%) 46 (63.0%) 41 (70.7%)
Grade 4/5 AE 34 (49.3%) 38 (52.1%) 32 (55.2%)

# Custom variable label behaviour works

Code
res
Output
A: Drug X B: Placebo C: Combination
—————————————————————————————————————————————————————————————————————————————————————
Total number of patients with at least one
SER 45 (65.2%) 46 (63.0%) 37 (63.8%)
REL 49 (71.0%) 48 (65.8%) 40 (69.0%)
CTC35 47 (68.1%) 46 (63.0%) 41 (70.7%)
CTC45 34 (49.3%) 38 (52.1%) 32 (55.2%)

---

Code
res
Output
A: Drug X B: Placebo C: Combination
—————————————————————————————————————————————————————————————————————————————————————
Total number of patients with at least one
Serious AE 45 (65.2%) 46 (63.0%) 37 (63.8%)
Related AE 49 (71.0%) 48 (65.8%) 40 (69.0%)
Grade 3-5 AE 47 (68.1%) 46 (63.0%) 41 (70.7%)
Grade 4/5 AE 34 (49.3%) 38 (52.1%) 32 (55.2%)

---

Code
res
Output
A: Drug X B: Placebo C: Combination
—————————————————————————————————————————————————————————————————————————————————————
Total number of patients with at least one
Category 1 45 (65.2%) 46 (63.0%) 37 (63.8%)
Category 2 49 (71.0%) 48 (65.8%) 40 (69.0%)
Category 3 47 (68.1%) 46 (63.0%) 41 (70.7%)
Category 4 34 (49.3%) 38 (52.1%) 32 (55.2%)

---

Code
res
Output
A: Drug X B: Placebo C: Combination
—————————————————————————————————————————————————————————————————————————————————————
Total number of patients with at least one
Serious AE 45 (65.2%) 46 (63.0%) 37 (63.8%)
Related AE 49 (71.0%) 48 (65.8%) 40 (69.0%)
Grade 3-5 AE 47 (68.1%) 46 (63.0%) 41 (70.7%)
Grade 4/5 AE 34 (49.3%) 38 (52.1%) 32 (55.2%)

7 changes: 3 additions & 4 deletions tests/testthat/test-count_patients_with_flags.R
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ testthat::test_that("Custom variable label behaviour works", {
CTC35 = AETOXGR %in% c("3", "4", "5"),
CTC45 = AETOXGR %in% c("4", "5")
)
columns <- c("SER", "REL", "CTC35", "CTC45")
aesi_vars <- c("SER", "REL", "CTC35", "CTC45")

# No variable labels (variable names used)
lyt <- basic_table() %>%
Expand All @@ -186,10 +186,9 @@ testthat::test_that("Custom variable label behaviour works", {
testthat::expect_snapshot(res)

labels <- c("Serious AE", "Related AE", "Grade 3-5 AE", "Grade 4/5 AE")
for (i in seq_along(columns)) {
attr(adae_local[[columns[i]]], "label") <- labels[i]
for (i in seq_along(aesi_vars)) {
attr(adae_local[[aesi_vars[i]]], "label") <- labels[i]
}
aesi_vars <- c("SER", "REL", "CTC35", "CTC45")

# Variable labels from df
lyt <- basic_table() %>%
Expand Down

0 comments on commit 0fb3ec3

Please sign in to comment.