Skip to content

Commit

Permalink
Merge pull request #89 from FredHutch/t
Browse files Browse the repository at this point in the history
Update t.test test expectations for new error in R >= 4.4
  • Loading branch information
slager authored Sep 4, 2024
2 parents 5a2752e + 5d63eff commit bd9c7fe
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tests/testthat/test_statistical_tests_and_estimates.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,19 @@ test_that("two_samp_cont_test testing various options (no errors)", {
# T-Test Unpaired
#t.test(x[1:10], x[13:22], paired=F, var.equal = F)$p.value
expect_equal(object = two_samp_cont_test(x = x, y = y, method = 't', paired = FALSE, verbose = T),
expected = t.test(x~factor(y), paired = F, var.equal = F)$p.value,
expected = t.test(x~factor(y), var.equal = F)$p.value,
tolerance = 1e-8)
# T-Test Paired
#Note the list also works: t.test(x[1:10], x[13:22], paired=T, var.equal = F)$p.value
expect_equal(object = two_samp_cont_test(x = x[-(11:12)], y = y[-(11:12)], method = 't', paired = TRUE, verbose = T),
expected = t.test(x[-c(1,10:13,22)]~factor(y[-c(1,10:13,22)]), paired = T, var.equal = F)$p.value,
expected = t.test(x[1:10], x[13:22], paired = T, var.equal = F)$p.value,
tolerance = 1e-8)
#Testing var.equal = T option in T-Test Unpaired
expect_equal(object = two_samp_cont_test(x = x, y = y, method = 't', paired = FALSE, verbose = T, var.equal = T),
expected = t.test(x~factor(y), paired = F, var.equal = T)$p.value,
expected = t.test(x~factor(y), var.equal = T)$p.value,
tolerance = 1e-8)
#Testing alternative param can be used
expect_equal(object = two_samp_cont_test(x = x, y = y, method = 't', paired = FALSE, verbose = T, alternative = 'less'),
expected = t.test(x~factor(y), paired = F, alternative = 'less')$p.value,
expected = t.test(x~factor(y), alternative = 'less')$p.value,
tolerance = 1e-8)

#Testing t.test where both levels of y have a single x value
Expand Down

0 comments on commit bd9c7fe

Please sign in to comment.