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

Fix integrations tests after ref_group update #1115

Merged
merged 1 commit into from
Nov 1, 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
10 changes: 6 additions & 4 deletions tests/testthat/test-compare_variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ testthat::test_that("s_compare for logical handles NAs as FALSE if not removed",

testthat::test_that("compare_vars works with default settings in rtables layout pipeline", {
lyt <- basic_table() %>%
split_cols_by("ARMCD", ref_group = "ARM B") %>%
split_cols_by("ARMCD", ref_group = "ARM B", split_fun = ref_group_position("first")) %>%
compare_vars(c("AGE", "SEX"))
result <- build_table(lyt, tern_ex_adsl)

Expand All @@ -102,7 +102,7 @@ testthat::test_that("compare_vars works with default settings in rtables layout

testthat::test_that("compare_vars works with custom settings", {
lyt <- basic_table() %>%
split_cols_by("ARMCD", ref_group = "ARM C") %>%
split_cols_by("ARMCD", ref_group = "ARM C", split_fun = ref_group_position("first")) %>%
compare_vars(
c("AGE", "SEX"),
.stats = c("mean_sd", "count_fraction", "pval"),
Expand All @@ -117,7 +117,7 @@ testthat::test_that("compare_vars works with custom settings", {

testthat::test_that("compare_vars 'na_str' argument works as expected", {
result <- basic_table() %>%
split_cols_by("ARMCD", ref_group = "ARM B") %>%
split_cols_by("ARMCD", ref_group = "ARM B", split_fun = ref_group_position("first")) %>%
compare_vars("ARM", na_str = "-") %>%
build_table(tern_ex_adsl)

Expand All @@ -132,7 +132,9 @@ testthat::test_that("create_afun_compare returns error message", {
})

testthat::test_that("a_compare returns correct output and warning message", {
testthat::expect_warning(result <- a_compare(rnorm(10, 5, 1), .ref_group = rnorm(20, -5, 1), .stats = c("n", "pval")))
testthat::expect_warning({
result <- a_compare(rnorm(10, 5, 1), .ref_group = rnorm(20, -5, 1), .stats = c("n", "pval"))
})
expected <- a_summary(rnorm(10, 5, 1), .ref_group = rnorm(20, -5, 1), .stats = c("n", "pval"), compare = TRUE)

testthat::expect_equal(result, expected)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-odds_ratio.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ testthat::test_that("estimate_odds_ratio estimates right OR and CI (stratified a
)

result <- basic_table() %>%
split_cols_by(var = "grp", ref_group = "A") %>%
split_cols_by(var = "grp", ref_group = "A", split_fun = ref_group_position("first")) %>%
estimate_odds_ratio(vars = "rsp", variables = list(arm = "grp", strata = "strata")) %>%
build_table(df = data)

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-prop_diff.R
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ testthat::test_that("`estimate_proportion_diff` and cmh is compatible with `rtab
stringsAsFactors = TRUE
)
l <- basic_table() %>%
split_cols_by(var = "grp", ref_group = "B") %>%
split_cols_by(var = "grp", ref_group = "B", split_fun = ref_group_position("first")) %>%
estimate_proportion_diff(
vars = "rsp",
variables = list(strata = c("f1", "f2")),
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-split_cols_by_groups.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ testthat::test_that("split_cols_by_groups equivalent to split_cols_by with ref_c
}
}
result <- basic_table() %>%
split_cols_by_groups("ARM", ref_group = "B: Placebo") %>%
split_cols_by_groups("ARM", ref_group = "B: Placebo", split_fun = ref_group_position("first")) %>%
add_colcounts() %>%
analyze("AGE", afun = afun) %>%
build_table(DM)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-summarize_glm_count.R
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ testthat::test_that("summarize_glm_count works with healthy inputs", {
filter(PARAMCD == "TNE")
anl$AVAL_f <- as.factor(anl$AVAL)
result <- basic_table() %>%
split_cols_by("ARM", ref_group = "B: Placebo") %>%
split_cols_by("ARM", ref_group = "B: Placebo", split_fun = ref_group_position("first")) %>%
add_colcounts() %>%
analyze_vars(
"AVAL_f",
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test-test_proportion_diff.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ testthat::test_that("test_proportion_diff returns right result", {
)

result <- basic_table() %>%
split_cols_by(var = "grp", ref_group = "B") %>%
split_cols_by(var = "grp", ref_group = "B", split_fun = ref_group_position("first")) %>%
test_proportion_diff(
vars = "rsp",
method = "cmh", variables = list(strata = "strat")
Expand All @@ -140,7 +140,7 @@ testthat::test_that("test_proportion_diff edge case: all responder by chisq", {
)

result <- basic_table() %>%
split_cols_by(var = "grp", ref_group = "B") %>%
split_cols_by(var = "grp", ref_group = "B", split_fun = ref_group_position("first")) %>%
test_proportion_diff(
vars = "rsp",
method = c("chisq", "schouten", "fisher", "cmh")[1]
Expand All @@ -158,7 +158,7 @@ testthat::test_that("test_proportion_diff edge case: all responder by schouten",
)

result <- basic_table() %>%
split_cols_by(var = "grp", ref_group = "B") %>%
split_cols_by(var = "grp", ref_group = "B", split_fun = ref_group_position("first")) %>%
test_proportion_diff(
vars = "rsp",
method = c("chisq", "schouten", "fisher", "cmh")[2]
Expand All @@ -176,7 +176,7 @@ testthat::test_that("test_proportion_diff edge case: all responder by fisher", {
)

result <- basic_table() %>%
split_cols_by(var = "grp", ref_group = "B") %>%
split_cols_by(var = "grp", ref_group = "B", split_fun = ref_group_position("first")) %>%
test_proportion_diff(
vars = "rsp",
var_labels = "Variable Label",
Expand All @@ -197,7 +197,7 @@ testthat::test_that("test_proportion_diff edge case: all responder by CMH", {
)

result <- basic_table() %>%
split_cols_by(var = "grp", ref_group = "B") %>%
split_cols_by(var = "grp", ref_group = "B", split_fun = ref_group_position("first")) %>%
test_proportion_diff(
vars = "rsp",
var_labels = "Variable Label",
Expand Down