tests/testthat/test-two-sample-robust.R

patrick::with_parameters_test_that(
  "t_robust works:",
  {
    set.seed(123)
    # `exec()` inlines the column names, as if they were typed in the call
    df <- rlang::exec(
      two_sample_test,
      type = "r",
      data = data,
      x = x,
      y = y,
      paired = paired,
      conf.level = conf.level,
      digits = digits
    )

    expect_snapshot(select(df, -expression))
    expect_snapshot(df[["expression"]])
  },
  .cases = dplyr::tibble(
    .test_name = c(
      "within-subjects without NAs",
      "within-subjects with NAs",
      "between-subjects without NAs",
      "between-subjects with NAs"
    ),
    data = list(
      iris_long_two_groups,
      bugs_long_two_groups,
      mtcars,
      msleep_two_groups
    ),
    x = c("condition", "condition", "am", "vore"),
    y = c("value", "desire", "wt", "brainwt"),
    paired = c(TRUE, TRUE, FALSE, FALSE),
    conf.level = c(0.95, 0.95, 0.99, 0.90),
    digits = c(4L, 3L, 3L, 4L)
  )
)

Try the statsExpressions package in your browser

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

statsExpressions documentation built on Nov. 14, 2026, 9:08 a.m.