tests/testthat/helper-fixtures.R

# Test-fixture helper:
# A replacement for dplyr::tibble to allow for dropping the dependency.
# Handles list columns nicely and enforces no strings as factors.
# Simple; no recycling or row names.
mk_df <- function(...) {
  cols <- list(...)
  n <- if (length(cols) > 0L) { length(cols[[1L]]) } else { 0L }
  structure(
    cols,
    names = names(cols),
    class = "data.frame",
    row.names = if (n > 0L) { c(NA_integer_, -n) } else { integer(0) }
  )
}

Try the structenforcement package in your browser

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

structenforcement documentation built on July 1, 2026, 5:07 p.m.