Skip to content

Commit

Permalink
adjust tests for "cannot use 'paired = TRUE' in formula method." error
Browse files Browse the repository at this point in the history
  • Loading branch information
rempsyc committed Apr 28, 2024
1 parent b0608e4 commit 21c6ad3
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions tests/testthat/test-htest_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -274,33 +274,35 @@ test_that("subset and na.action", {
# necessary here.

# paired t-test with formula
before <- c(200.1, 190.9, 192.7, 213, 241.4, 196.9, 172.2, 185.5, NA, 999)
after <- c(392.9, 393.2, 345.1, 393, 434, 427.9, 422, 383.9, NA, 999)
my_data <- data.frame(
group = rep(c("before", "after"), each = 10),
weight = c(before, after),
stringsAsFactors = FALSE
)

res <- t.test(weight ~ group,
data = my_data, paired = TRUE,
alternative = "less", na.omit = TRUE
)

d1 <- effectsize(
res,
data = my_data,
subset = weight < 999,
na.action = na.omit
)

d2 <- cohens_d(weight ~ group,
data = my_data,
paired = TRUE,
alternative = "less",
subset = weight < 999,
na.action = na.omit
)

expect_equal(d1, d2, ignore_attr = TRUE)
# Removing this test because paired t-test with formula isn't supported anymore
#
# before <- c(200.1, 190.9, 192.7, 213, 241.4, 196.9, 172.2, 185.5, NA, 999)
# after <- c(392.9, 393.2, 345.1, 393, 434, 427.9, 422, 383.9, NA, 999)
# my_data <- data.frame(
# group = rep(c("before", "after"), each = 10),
# weight = c(before, after),
# stringsAsFactors = FALSE
# )
#
# res <- t.test(weight ~ group,
# data = my_data, paired = TRUE,
# alternative = "less", na.omit = TRUE
# )
#
# d1 <- effectsize(
# res,
# data = my_data,
# subset = weight < 999,
# na.action = na.omit
# )
#
# d2 <- cohens_d(weight ~ group,
# data = my_data,
# paired = TRUE,
# alternative = "less",
# subset = weight < 999,
# na.action = na.omit
# )
#
# expect_equal(d1, d2, ignore_attr = TRUE)
})

0 comments on commit 21c6ad3

Please sign in to comment.