UC-Branded Tables

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  warning = FALSE,
  message = FALSE
)

Overview

Rbearcat provides three table functions that apply UC styling automatically:

| Function | Purpose | |---|---| | bcat_reg_table() | Regression results (wraps modelsummary) | | bcat_sum_table() | Descriptive / summary statistics | | bcat_cor_table() | Correlation matrix with significance stars |

All three auto-detect the output format (HTML, PDF, Word) and style accordingly.

library(Rbearcat)

Regression Tables with bcat_reg_table()

Single Model

m1 <- lm(mpg ~ wt + hp, data = mtcars)
bcat_reg_table(m1, caption = "Model 1: MPG predicted by Weight and Horsepower")

Comparing Multiple Models

Pass a named list of models to display them side by side:

m2 <- lm(mpg ~ wt + hp + cyl, data = mtcars)
m3 <- lm(mpg ~ wt + hp + cyl + disp, data = mtcars)

bcat_reg_table(
  list("Base" = m1, "Add Cylinders" = m2, "Full" = m3),
  caption = "Comparing Nested OLS Models"
)

Robust Standard Errors

Use se_type to pass a heteroskedasticity-consistent variance estimator:

bcat_reg_table(m1, se_type = "HC1", caption = "HC1 Robust Standard Errors")

Custom Coefficient Names and GOF

bcat_reg_table(
  m2,
  coef_rename = c("wt" = "Weight (1000 lbs)",
                   "hp" = "Horsepower",
                   "cyl" = "Cylinders"),
  gof_map = c("nobs", "r.squared", "adj.r.squared"),
  caption = "Custom Labels"
)

Changing Significance Stars

bcat_reg_table(
  m1,
  stars = c("+" = 0.1, "*" = 0.05, "**" = 0.01, "***" = 0.001),
  caption = "Alternative Star Convention"
)

Summary Statistics with bcat_sum_table()

Basic Usage

Pass a data frame (or subset of columns) to get mean, SD, min, median, max, N, and percent missing:

bcat_sum_table(
  mtcars[, c("mpg", "wt", "hp", "qsec")],
  caption = "Descriptive Statistics for mtcars"
)

Grouped Summaries

Use by to compute statistics within groups:

bcat_sum_table(
  mtcars[, c("mpg", "wt", "hp", "cyl")],
  by = "cyl",
  caption = "Summary Statistics by Cylinder Count"
)

Selecting Statistics

Choose only the statistics you need:

bcat_sum_table(
  mtcars[, c("mpg", "hp")],
  stats = c("mean", "sd", "n"),
  caption = "Mean, SD, and N Only"
)

Correlation Matrices with bcat_cor_table()

Basic Correlation Matrix

By default, shows the lower triangle with Pearson correlations and significance stars:

bcat_cor_table(
  mtcars[, c("mpg", "wt", "hp", "disp", "qsec")],
  caption = "Pearson Correlation Matrix"
)

Full Matrix with Spearman Method

bcat_cor_table(
  mtcars[, c("mpg", "wt", "hp")],
  method = "spearman",
  full_matrix = TRUE,
  caption = "Full Spearman Correlation Matrix"
)

Without Stars

bcat_cor_table(
  mtcars[, c("mpg", "wt", "hp")],
  stars = FALSE,
  caption = "Correlation Matrix (No Stars)"
)

General Table Styling with bcat_fmt_style_table()

For any data frame, bcat_fmt_style_table() applies UC header colors and formatting:

bcat_fmt_style_table(
  head(iris, 8),
  caption = "Iris Sample",
  striped = TRUE
)

Spanning Headers

bcat_fmt_style_table(
  head(iris, 5),
  header = "Iris Dataset — First 5 Rows",
  caption = "With Spanning Header"
)

Customizing Appearance

All table functions share these styling parameters:

| Parameter | Default | Description | |---|---|---| | header_bg_color | UC Red | Header background color | | header_txt_color | "white" | Header text color | | font_size | 12 | Font size | | striped | TRUE | Zebra-striped rows | | caption | NULL | Table caption | | footer | NULL | Table footnote |

bcat_reg_table(
  m1,
  header_bg_color = palette_UC[["Bearcats Black"]],
  font_size = 11,
  footer = "Source: mtcars dataset",
  caption = "Custom Styled Table"
)


Try the Rbearcat package in your browser

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

Rbearcat documentation built on March 21, 2026, 5:07 p.m.