Skip to content

Commit 35ea116

Browse files
committed
fix some more tests about wilcoxon test in R4.6+
1 parent 715ea64 commit 35ea116

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

tests/testthat/test-options.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ test_that("All options work", {
101101
)
102102
ct_opt = crosstable(mtcars3, c(cyl, carb, qsec_posix, surv), by=vs, test=TRUE, effect=TRUE) %>%
103103
suppressWarnings()
104+
105+
if (getRversion() > "4.6") {
106+
valR4.5 = "p value: 0.0002 \n(Wilcoxon rank sum test)"
107+
valR4.6 = "p value: <0.0001 \n(Wilcoxon rank sum exact test)"
108+
if (unique(x$test[11:14]) != valR4.6) {
109+
stop("Error in wilcoxon exact test in R>4.6")
110+
}
111+
x$test[11:14] = valR4.5
112+
}
113+
104114
expect_snapshot({
105115
as.data.frame(ct_noopt)
106116
as.data.frame(ct_opt)

tests/testthat/test-tests.R

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,16 @@ test_that("Testing everything", {
108108
test=TRUE, effect=TRUE)
109109
# expect_warning(class="crosstable_effect_warning")
110110
ft = as_flextable(x)
111-
111+
112+
if (getRversion() > "4.6") {
113+
valR4.5 = "p value: 0.0002 \n(Wilcoxon rank sum test)"
114+
valR4.6 = "p value: <0.0001 \n(Wilcoxon rank sum exact test)"
115+
if (unique(x$test[1:4]) != valR4.6) {
116+
stop("Error in wilcoxon exact test in R>4.6")
117+
}
118+
x$test[1:4] = valR4.5
119+
}
120+
112121
expect_snapshot(as.data.frame(x))
113122
expect_snapshot(ft)
114123
})

0 commit comments

Comments
 (0)