Skip to content

Commit

Permalink
Merge cbd9859 into 13391c7
Browse files Browse the repository at this point in the history
  • Loading branch information
bzkrouse authored Apr 25, 2024
2 parents 13391c7 + cbd9859 commit db3193d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
10 changes: 9 additions & 1 deletion R/ard_stack.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,15 @@ ard_stack <- function(data,
ard_list <- c(
ard_list,
.eval_ard_calls(data, by = character(0), ...)
)
) |>
bind_ard()

# fill group variables just for shuffling
if (isTRUE(.shuffle)) {
# fill group variables just for shuffling
ard_list <- ard_list |>
tidyr::fill(all_ard_groups(types = "names"), .direction = "downup")
}
}

# compute Ns by group / combine main calls
Expand Down
30 changes: 30 additions & 0 deletions tests/testthat/test-ard_stack.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,33 @@ test_that("ard_stack() .shuffle argument", {
shuffle_ard()
)
})



test_that("ard_stack() .shuffle + .overall", {
expect_error(
ard_test <- ard_stack(
data = mtcars,
by = "cyl",
ard_continuous(variables = "mpg"),
ard_dichotomous(variables = "vs"),
.shuffle = TRUE,
.overall = TRUE
),
NA
)

expect_equal(
ard_test,
bind_ard(
ard_continuous(data = mtcars, by = "cyl", variables = "mpg"),
ard_dichotomous(data = mtcars, by = "cyl", variables = "vs"),
ard_continuous(data = mtcars, variables = "mpg"),
ard_dichotomous(data = mtcars, variables = "vs"),
ard_categorical(data = mtcars, variables = "cyl"),
.order = TRUE
) |>
shuffle_ard() |>
dplyr::mutate(cyl = ifelse(is.na(cyl), "Overall cyl", cyl))
)
})

0 comments on commit db3193d

Please sign in to comment.