Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edelarua committed Jun 6, 2023
1 parent 3029840 commit 943821e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
7 changes: 6 additions & 1 deletion R/summarize_variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,12 @@ s_summary.character <- function(x,
.var,
verbose = TRUE,
...) {
y <- as_factor_keep_attributes(x, x_name = .var, verbose = verbose)
if (na.rm) {
y <- as_factor_keep_attributes(x, x_name = .var, verbose = verbose)
} else {
y <- as_factor_keep_attributes(x, x_name = .var, verbose = verbose, na_level = "NA")
}

s_summary(
x = y,
na.rm = na.rm,
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/summarize_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@
$count$Unknown
[1] 4
$count$`<Missing>`
$count$`NA`
[1] 1
Expand All @@ -858,7 +858,7 @@
$count_fraction$Unknown
[1] 4.0 0.4
$count_fraction$`<Missing>`
$count_fraction$`NA`
[1] 1.0 0.1
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/survival_time.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
———————————————————————————————————————————————————————————————————
Survival Time (Months)
Median 32.0 23.9 20.8
95% CI (22.5, 49.3) (18.3, 32.9) (12.9, 26.0)
95% CI (22.5, 49.3) (18.3, 32.9) (12.9, 26.0)
25% and 75%-ile 17.4, 65.3 9.8, 42.0 7.3, 37.1
Range (censored) 0.8 to 63.5 6.2 to 78.9 3.4 to 52.4
Range (event) 0.3 to 155.5 0.1 to 154.1 0.6 to 80.7
Expand All @@ -93,7 +93,7 @@
———————————————————————————————————————————————————————————————————
Survival Time (Months)
Median 32.0 23.9 20.8
90% CI (25.6, 49.3) (18.9, 32.1) (13.0, 26.0)
90% CI (25.6, 49.3) (18.9, 32.1) (13.0, 26.0)
40% and 60%-ile 25.6, 46.5 18.3, 29.2 13.0, 25.7
Range (censored) 0.8 to 63.5 6.2 to 78.9 3.4 to 52.4
Range (event) 0.3 to 155.5 0.1 to 154.1 0.6 to 80.7
Expand Down
28 changes: 15 additions & 13 deletions tests/testthat/_snaps/survival_timepoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@
—————————————————————————————————————————————————————————————————————————
9 Months
Difference in Event Free Rate -9.64 -13.03
95% CI (-22.80, 3.52) (-27.59, 1.53)
p-value (Z-test) 0.1511 0.0794
95% CI (-22.80, 3.52) (-27.59, 1.53)
p-value (Z-test) 0.1511 0.0794

# surv_timepoint for survival diff works with customized arguments

Expand All @@ -163,20 +163,22 @@
—————————————————————————————————————————————————————————————————————————
9 Months
Difference in Event Free Rate -9.64 -13.03
99% CI (-26.94, 7.66) (-32.17, 6.10)
p-value (Z-test) 0.1511 0.0794
99% CI (-26.94, 7.66) (-32.17, 6.10)
p-value (Z-test) 0.1511 0.0794

# surv_timepoint works with method = both

Code
res
result
Output
AVAL CHG
———————————————————
V1
mean 6 0
V2
mean 5 -1
V3
mean 4 -2
ARM A ARM B ARM C
(N=69) (N=73) (N=58)
——————————————————————————————————————————————————————————————————————————————————
9 Months
Patients remaining at risk 53 53 39
Event Free Rate (%) 84.89 75.25 71.86
95% CI (76.24, 93.53) (65.32, 85.17) (60.14, 83.57)
Difference in Event Free Rate -9.64 -13.03
95% CI (-22.80, 3.52) (-27.59, 1.53)
p-value (Z-test) 0.1511 0.0794

0 comments on commit 943821e

Please sign in to comment.