Cheatsheet

Quick reference for tabviz functions and arguments.

Visual Layout

+---------------------------------------------------------------------------+
|  [title]                                                                  |
|  [subtitle]                                                               |
+---------------------------------------------------------------------------+
| [label column]  [left columns...]  | FOREST PLOT |  [right columns...]    |
|                                    |             |                        |
| > Group Header                     |    null_    |                        |
|   Study A        N    Events       | <--*-->     |   HR (95% CI)   P-val  |
|   Study B        N    Events       |    <--*-->  |   HR (95% CI)   P-val  |
|   Study C        N    Events       |  <--*-->    |   HR (95% CI)   P-val  |
|                                    |     value   |                        |
| > Another Group                    |      |      |                        |
|   Study D        N    Events       |   <--*-->   |   HR (95% CI)   P-val  |
+---------------------------------------------------------------------------+
|  [axis_label]                                                             |
+---------------------------------------------------------------------------+
|  [caption]                                                  [footnote]    |
+---------------------------------------------------------------------------+

Core Functions

tabviz() - Main Entry Point

tabviz(
  data,                 # data.frame
  label = "study",      # column with row labels
  group = "category",   # column(s) for grouping
  columns = list(       # col_*() specifications
    col_text("category"),
    viz_forest(point = "hr", lower = "lo", upper = "hi"),
    col_numeric("n")
  ),
  theme = web_theme_jama()
)

tabviz() with viz_forest() - Forest Plot

tabviz(
  data,                 # data.frame
  label = "study",      # column with row labels
  group = "category",   # column(s) for grouping
  columns = list(
    viz_forest(
      point = "hr",     # column with point estimates
      lower = "lower",  # column with lower CI
      upper = "upper",  # column with upper CI
      scale = "log",    # "log" or "linear"
      null_value = 1,   # reference line value
      axis_label = "HR" # x-axis label
    ),
    ...                 # additional col_*() specifications
  ),
  theme = web_theme_jama()
)

Visualization Columns (viz_*)

Focal visualizations with their own axes and scales:

Function Purpose Example
viz_forest() Forest plots with CI viz_forest(point = "hr", lower = "lo", upper = "hi", scale = "log")
viz_bar() Bar charts with axis viz_bar(effect_bar("value"))
viz_boxplot() Box-and-whisker plots viz_boxplot(effect_boxplot(data = "values"))
viz_violin() Violin/density plots viz_violin(effect_violin(data = "values"))

Data Columns (col_*)

Function Purpose Example
col_text() Text values col_text("category")
col_numeric() Formatted numbers col_numeric("n", decimals = 0)
col_interval() Point (CI) format col_interval(point = "hr", lower = "lo", upper = "hi")
col_n() Sample sizes col_n("n", abbreviate = TRUE)
col_percent() Percentages col_percent("rate")
col_events() Events/N format col_events("events", "n")
col_pvalue() P-values with stars col_pvalue("pval", stars = TRUE)
col_bar() Inline horizontal bars col_bar("weight")
col_sparkline() Mini charts col_sparkline("trend")
col_badge() Colored badges col_badge("status")
col_icon() Icons/emoji col_icon("flag")
col_stars() Star ratings col_stars("quality")
col_img() Inline images col_img("logo_url")
col_reference() Truncated links col_reference("doi")
col_range() Min-max ranges col_range("min", "max")
col_group() Group columns col_group("Results", col_interval(...), col_pvalue("p"))

Row Styling Arguments

Argument Values Effect
row_type "data", "header", "summary", "spacer" Row behavior
row_bold TRUE/FALSE Bold text
row_italic TRUE/FALSE Italic text
row_color CSS color Text color
row_bg CSS color Background color
row_indent 0, 1, 2 Indentation level
row_badge Text Badge label
row_emphasis TRUE/FALSE Bold + primary color
row_muted TRUE/FALSE Lighter color
row_accent TRUE/FALSE Accent color

All accept column names or formula expressions: row_bold = ~ pval < 0.05


Marker Styling Arguments

Argument Values Effect
marker_color CSS color Fill color
marker_shape "square", "circle", "diamond", "triangle" Shape
marker_opacity 0 to 1 Transparency
marker_size Multiplier Size (1 = default)

All accept column names or formula expressions: marker_color = ~ ifelse(sig, "green", "gray")


Built-in Themes

Theme Style
web_theme_default() Clean, modern default
web_theme_jama() JAMA publication style
web_theme_lancet() Lancet publication style
web_theme_nature() Nature publication style
web_theme_cochrane() Cochrane review style
web_theme_modern() Contemporary with gradients
web_theme_presentation() Large text for slides
web_theme_dark() Dark mode
web_theme_minimal() Maximum density

Theme Modifier Functions

tabviz(..., theme = web_theme_default() |>
  set_colors(primary = "#2563eb", ...) |>
  set_typography(font_family = "Georgia", font_size_base = "0.9rem") |>
  set_spacing(row_height = 28, header_height = 32) |>
  set_shapes(point_size = 6, line_width = 1.5) |>
  set_axis(gridlines = TRUE, gridline_style = "dashed")
)

Fluent API (Pipe-Based)

tabviz(data, label = "study", columns = list(viz_forest(...))) |>
  set_row_style(bold = ~ pval < 0.05, emphasis = "is_primary") |>
  set_marker_style(color = ~ ifelse(upper < 1, "#16a34a", "#94a3b8")) |>
  set_column_style("hr", bold = ~ .x < 1, color = ~ ifelse(.x < 1, "green", "red")) |>
  set_theme("jama")

Formula Expressions (NSE)

Row/Marker styling - reference any column:

row_bold = ~ pval < 0.05
marker_color = ~ case_when(
  upper < 1 ~ "#16a34a",  # Significant benefit
  lower > 1 ~ "#dc2626",  # Significant harm
  TRUE ~ "#64748b"        # Not significant
)

Cell styling - use .x for the column’s own values:

col_pvalue("pval", bold = ~ .x < 0.05)
col_numeric("hr", color = ~ ifelse(.x < 1, "green", "red"))

Interactivity

# Tooltips on hover
interaction = web_interaction(tooltip_fields = c("n", "events", "pvalue"))

# Read-only (no sorting/selection)
interaction = web_interaction_minimal()

# Fully static (for print)
interaction = web_interaction_publication()

Multiple Effects (Forest)

tabviz(data, label = "study", columns = list(
  viz_forest(
    effects = list(
      effect_forest("itt_hr", "itt_lo", "itt_hi", label = "ITT", color = "#2563eb"),
      effect_forest("pp_hr", "pp_lo", "pp_hi", label = "Per-Protocol", color = "#16a34a")
    ),
    scale = "log", null_value = 1
  )
))

Distribution Visualizations

# Bar chart
viz_bar(
  effect_bar("value", color = "#3b82f6"),
  axis_range = c(0, 100)
)

# Boxplot from array data
viz_boxplot(
  effect_boxplot(data = "measurements", color = "#8b5cf6"),
  show_outliers = TRUE
)

# Boxplot from pre-computed stats
viz_boxplot(
  effect_boxplot(min = "min", q1 = "q1", median = "median", q3 = "q3", max = "max")
)

# Violin plot
viz_violin(
  effect_violin(data = "scores", color = "#f59e0b"),
  show_median = TRUE, show_quartiles = TRUE
)

Annotations

annotations = list(
  refline(0.8, label = "Threshold", style = "dashed", color = "#e11d48")
)

Split Plots

# Single variable split
tabviz(data, label = "study", columns = list(viz_forest(...)), split_by = "region")

# Hierarchical split
tabviz(data, label = "study", columns = list(viz_forest(...)), split_by = c("region", "country"), shared_axis = TRUE)

Exporting

# Save to file
p <- tabviz(data, ...)
save_plot(p, "plot.svg")               # Vector
save_plot(p, "plot.png", scale = 2)    # Raster (2x resolution)
save_plot(p, "plot.pdf")               # Print

Quick Patterns

# Log scale for ratios
viz_forest(point = "hr", lower = "lo", upper = "hi", scale = "log", null_value = 1)

# Linear scale for differences
viz_forest(point = "md", lower = "lo", upper = "hi", scale = "linear", null_value = 0)

# Significant results bold
row_bold = ~ pval < 0.05

# Color by direction
marker_color = ~ ifelse(upper < 1, "#16a34a", "#94a3b8")

# Column groups
col_group("Treatment", col_n("n_tx"), col_events("ev_tx", "n_tx"))

# Hierarchical grouping
group = c("region", "country")