tests/testthat/test-single-row-df.R

test_that("multiplication works", {
  library(tablespan)
  library(dplyr)
  data("mtcars")

  # We want to report the following table:
  summarized_table <- mtcars |>
    group_by(cyl, vs) |>
    summarise(N = n(),
              mean_hp = mean(hp),
              sd_hp = sd(hp),
              mean_wt = mean(wt),
              sd_wt = sd(wt))

  tablespan(summarized_table[1,],
            formula = as.formula(paste0("1 ~ ", paste0(colnames(summarized_table), collapse = " + "))))
})

Try the tablespan package in your browser

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

tablespan documentation built on Sept. 10, 2025, 10:35 a.m.