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

fixing g_forest for older versions of testthat #803

Merged
merged 5 commits into from
Jan 22, 2023
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
7 changes: 4 additions & 3 deletions R/g_forest.R
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ g_forest <- function(tbl, # nolint
}

x_e <- vapply(seq_len(nr), function(i) {
xi <- as.vector(tbl[i, col_x, drop = TRUE])
# If a label row is selected NULL is returned with a warning (suppressed)
xi <- suppressWarnings(as.vector(tbl[i, col_x, drop = TRUE]))

if (!is.null(xi) && !(length(xi) <= 0) && is.numeric(xi)) {
xi
Expand All @@ -193,7 +194,7 @@ g_forest <- function(tbl, # nolint
}, numeric(1))

x_ci <- lapply(seq_len(nr), function(i) {
xi <- as.vector(tbl[i, col_ci, drop = TRUE])
xi <- suppressWarnings(as.vector(tbl[i, col_ci, drop = TRUE])) # as above

if (!is.null(xi) && !(length(xi) <= 0) && is.numeric(xi)) {
if (length(xi) != 2) {
Expand All @@ -210,7 +211,7 @@ g_forest <- function(tbl, # nolint

symbol_size <- if (!is.null(col_symbol_size)) {
tmp_symbol_size <- vapply(seq_len(nr), function(i) {
xi <- as.vector(tbl[i, col_symbol_size, drop = TRUE])
suppressWarnings(xi <- as.vector(tbl[i, col_symbol_size, drop = TRUE]))

if (!is.null(xi) && !(length(xi) <= 0) && is.numeric(xi)) {
xi
Expand Down
372 changes: 186 additions & 186 deletions tests/testthat/_snaps/table_aet02.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/testthat/_snaps/table_aet02_smq.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
A: Drug X B: Placebo C: Combination
(N=134) (N=134) (N=132)
—————————————————————————————————————————————————————————————————————————————————————————————————————
Total number of patients with at least one adverse event 72 (53.7%) 79 (59%) 75 (56.8%)
Total number of patients with at least one adverse event 72 (53.7%) 79 (59.0%) 75 (56.8%)
SMQ01NAM
Total number of patients with at least one adverse event 72 (53.7%) 79 (59%) 75 (56.8%)
Total number of patients with at least one adverse event 72 (53.7%) 79 (59.0%) 75 (56.8%)
Overall total number of events 119 139 141
dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%)
dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%)
Expand All @@ -28,7 +28,7 @@
dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%)
dcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%)
SMQ01NAM
Total number of patients with at least one adverse event 72 (53.7%) 79 (59%) 75 (56.8%)
Total number of patients with at least one adverse event 72 (53.7%) 79 (59.0%) 75 (56.8%)
Overall total number of events 119 139 141
dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%)
dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%)
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/_snaps/table_aet04_pi.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
(N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132)
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
cl A.1
Total number of patients with at least one adverse event 78 (58.2%) 0 0 75 (56%) 0 0 89 (67.4%) 0 0
Total number of patients with at least one adverse event 78 (58.2%) 0 0 75 (56.0%) 0 0 89 (67.4%) 0 0
dcd A.1.1.1.1 37 0 0 34 0 0 48 0 0
dcd A.1.1.1.2 36 0 0 36 0 0 38 0 0
cl B.2
Total number of patients with at least one adverse event 79 (59%) 49 (36.6%) 0 74 (55.2%) 44 (32.8%) 0 85 (64.4%) 52 (39.4%) 0
Total number of patients with at least one adverse event 79 (59.0%) 49 (36.6%) 0 74 (55.2%) 44 (32.8%) 0 85 (64.4%) 52 (39.4%) 0
dcd B.2.2.3.1 36 0 0 40 0 0 39 0 0
dcd B.2.1.2.1 37 37 0 33 33 0 39 39 0
cl D.1
Total number of patients with at least one adverse event 79 (59%) 48 (35.8%) 50 (37.3%) 67 (50%) 42 (31.3%) 42 (31.3%) 80 (60.6%) 50 (37.9%) 51 (38.6%)
Total number of patients with at least one adverse event 79 (59.0%) 48 (35.8%) 50 (37.3%) 67 (50.0%) 42 (31.3%) 42 (31.3%) 80 (60.6%) 50 (37.9%) 51 (38.6%)
dcd D.1.1.1.1 37 0 37 31 0 31 39 0 39
dcd D.1.1.4.2 36 36 0 31 31 0 38 38 0
cl D.2
Expand Down
Loading