tests/testthat/test-tidy_ard_row_order.R

test_that("tidy_ard_row_order() works", {
  skip_if_pkg_not_installed("withr")
  withr::local_options(list(width = 120))
  withr::local_seed(1)

  # ensure rows are ordered within descending groups but not variables
  expect_snapshot(
    data.frame(
      x1 = sample(LETTERS[1:5], 30, replace = TRUE),
      x2 = sample(LETTERS[6:10], 30, replace = TRUE),
      x3 = sample(LETTERS[11:15], 30, replace = TRUE),
      zz = 1L,
      aa = 1L
    ) |>
      ard_tabulate(
        by = x1:x3,
        variables = c(zz, aa),
        statistic = everything() ~ "n"
      ) |>
      dplyr::select(all_ard_groups(), all_ard_variables())
  )
})

Try the cards package in your browser

Any scripts or data that you put into this service are public.

cards documentation built on Dec. 2, 2025, 9:07 a.m.