Create a collection of separate forest plots split by categorical variable values, with interactive sidebar navigation.

Usage

split_table(x, by, shared_axis = FALSE, ...)

Arguments

Argument Description
x A WebSpec object or data frame
by Column name(s) for splitting. Single string or character vector for hierarchical splits
shared_axis If TRUE, use the same axis range across all plots (default: FALSE)
... Additional arguments passed to web_spec() if x is a data frame

Value

A SplitForest object containing multiple WebSpec objects, one per unique combination of split values.

Details

Single Variable Split

split_table(spec, by = "region")

Creates one plot per unique value in the region column.

Hierarchical Split

split_table(spec, by = c("sex", "age_group"))

Creates plots for each combination (e.g., Male/Young, Male/Old, Female/Young, Female/Old) with nested navigation.

Shared Axis

split_table(spec, by = "region", shared_axis = TRUE
)

Forces all sub-plots to use the same axis range, enabling visual comparison across subgroups.

Examples

Basic Split

Code
set.seed(42)
data <- data.frame(
  study = paste0("Study ", 1:30),
  region = sample(c("Americas", "Europe", "Asia"), 30, replace = TRUE),
  or = exp(rnorm(30, log(0.8), 0.3)),
  lower = NA, upper = NA
)
data$lower <- data$or * exp(-1.96 * 0.25)
data$upper <- data$or * exp(1.96 * 0.25)

forest_plot(data,
  point = "or", lower = "lower", upper = "upper",
  label = "study",
  split_by = "region",
  scale = "log", null_value = 1,
  theme = web_theme_modern()
)

Hierarchical Split

Use a vector of column names for nested navigation:

forest_plot(data,
  point = "or", lower = "lower", upper = "upper",
  label = "study",
  split_by = c("sex", "age_group"),  # Creates nested tree navigation
  scale = "log", null_value = 1
)

See Also