Rbearcat

Rbearcat is an R package for econometrics and data science that provides University of Cincinnati branded themes, publication-ready plots, formatted tables, number formatters, and report templates for R Markdown, Bookdown, and Quarto.

Installation

Install the released version from CRAN:

install.packages("Rbearcat")

Or install the development version from GitHub:

# install.packages("pak")
# pak::pak("saannidhya/Rbearcat")
install.packages("Rbearcat", repos = c('https://saannidhya.r-universe.dev', 'https://cloud.r-project.org'))

Overview

Rbearcat gives you a consistent, UC-branded toolkit for the full reporting pipeline:

Category Functions Purpose
Plots bcat_plt_* (9 functions) Publication-ready ggplot2 charts
Tables bcat_reg_table, bcat_sum_table, bcat_cor_table Regression, summary statistics, and correlation tables
Formatters bcat_fmt_* (7 functions) Dollar, percent, comma, p-value, date, and scientific notation
Themes theme_UC* (4 themes) UC-branded ggplot2 themes with gridline variants
Color scales scale_color_UC, scale_fill_UC, etc. UC and Okabe-Ito (colorblind-safe) palettes
Templates R Markdown, Beamer, Xaringan, Bookdown, Quarto Branded document, presentation, and book formats
Utilities bcat_import_data, bcat_setup_rmd, etc. Data import, project setup, git helpers

Quick start

library(Rbearcat)

# Apply UC default colors to all geoms
set_UC_geoms()

# Scatter plot with UC theming
bcat_plt_point(iris,
               x = Sepal.Length,
               y = Sepal.Width,
               color = Species,
               smooth = TRUE)

# Bar chart
bcat_plt_bar(iris, x = Species, fill = Species)

# Histogram with density curve
bcat_plt_hist(iris, x = Sepal.Length, fill = Species, density = TRUE)

Plots

Nine plot functions wrap ggplot2 with UC themes and a consistent interface. Every function returns a ggplot object that you can customize with +.

Function Chart type
bcat_plt_bar() Bar chart (counts, identity, or summary stats)
bcat_plt_line() Line chart with optional ribbons and highlights
bcat_plt_point() Scatter plot with optional smoothing
bcat_plt_area() Stacked or filled area chart
bcat_plt_hist() Histogram with optional density curve
bcat_plt_box() Box plot or violin plot with jitter
bcat_plt_coef() Coefficient (forest) plot for model comparison
bcat_plt_diag() Regression diagnostic dashboard (4 panels)
bcat_plt_ts() Time series with decomposition and ACF/PACF
# Line plot
bcat_plt_line(economics, x = date, y = unemploy,
              title = "US Unemployment Over Time")

# Coefficient plot comparing two models
m1 <- lm(mpg ~ wt + hp, data = mtcars)
m2 <- lm(mpg ~ wt + hp + disp, data = mtcars)
bcat_plt_coef(list("Model 1" = m1, "Model 2" = m2))

# Diagnostic dashboard
bcat_plt_diag(m1)

Tables

# Regression table (supports lm, glm, fixest, plm, ivreg)
m1 <- lm(mpg ~ wt, data = mtcars)
m2 <- lm(mpg ~ wt + hp, data = mtcars)
bcat_reg_table(list("(1)" = m1, "(2)" = m2),
               stars = c("*" = 0.1, "**" = 0.05, "***" = 0.01))

# Summary statistics table
bcat_sum_table(mtcars[, c("mpg", "wt", "hp")],
               caption = "Descriptive Statistics")

# Correlation matrix with significance stars
bcat_cor_table(mtcars[, c("mpg", "wt", "hp", "disp")])

Number formatters

Format values for inline reporting in R Markdown or Quarto:

bcat_fmt_dollar(12345.67)
#> "$12,345.67"

bcat_fmt_percent(0.052)
#> "5.2%"

bcat_fmt_pvalue(0.003, add_p = TRUE)
#> "p = 0.003"

bcat_fmt_comma(1500000)
#> "1,500,000"

Use inline: `r bcat_fmt_dollar(avg_price)` renders as $12,345.67 in your document.

Themes and color palettes

Themes

Four ggplot2 themes with UC typography and colors:

library(ggplot2)

ggplot(iris, aes(Sepal.Length, Sepal.Width)) +
  geom_point() +
  theme_UC()          # Both gridlines

# Variants
theme_UC_hgrid()      # Horizontal gridlines only
theme_UC_vgrid()      # Vertical gridlines only
theme_UC_nogrid()     # No gridlines

Color palettes

# UC official brand palette (11 colors)
palette_UC

# Okabe-Ito colorblind-friendly palette (8 colors)
palette_OkabeIto

# Use as ggplot2 scales
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
  geom_point() +
  scale_color_UC() +
  theme_UC()

# Colorblind-safe alternative
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
  geom_point() +
  scale_color_OkabeIto() +
  theme_UC()

Available scale functions:

Scale Variants
UC scale_color_UC(), scale_fill_UC()
Okabe-Ito scale_color_OkabeIto(), scale_fill_OkabeIto()
Okabe-Ito (light) scale_color_OkabeIto_light(), scale_fill_OkabeIto_light()

Templates

R Markdown

Create a new UC-branded R Markdown document from RStudio:

File > New File > R Markdown > From Template

Template Output formats
UC R Markdown HTML, PDF, Word
UC Beamer PDF slides
UC Xaringan HTML slides

Or use the output formats directly in your YAML header:

output:
  Rbearcat::UC_html_document: default
  Rbearcat::UC_pdf_document: default
  Rbearcat::UC_word_document: default

Bookdown

output:
  Rbearcat::bcat_gitbook: default
  Rbearcat::bcat_pdf_book: default

Quarto

Create a Quarto project from a template:

bcat_new_quarto(type = "html", path = "my-report")
bcat_new_quarto(type = "pdf", path = "my-report")
bcat_new_quarto(type = "revealjs", path = "my-slides")

Vignettes

Detailed guides are available as package vignettes:

vignette("getting-started", package = "Rbearcat")
vignette("plots", package = "Rbearcat")
vignette("tables", package = "Rbearcat")
vignette("formatting", package = "Rbearcat")

Contributing

Issues and pull requests are welcome at github.com/saannidhya/Rbearcat.

License

MIT