tests/testthat/helper-subject-id.R

# Supplying `subject.id` for paired data should give the same result as
# relying on the row order of data already sorted by subject.
expect_subject_id_invariance <- function(.f, data, ...) {
  set.seed(123)
  with_id <- .f(
    data = data,
    x = condition,
    y = score,
    subject.id = id,
    paired = TRUE,
    ...
  )

  set.seed(123)
  sorted_by_id <- .f(
    data = arrange(data, id),
    x = condition,
    y = score,
    paired = TRUE,
    ...
  )

  expect_identical(with_id, sorted_by_id)
}

Try the statsExpressions package in your browser

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

statsExpressions documentation built on Oct. 17, 2026, 9:06 a.m.