Draws a study-level traffic-light plot of risk-of-bias judgments and a component-level stacked bar plot of percentages (Low, Unclear, High).

risk_of_bias_plot(
  data,
  study,
  component,
  decision,
  study_order = NULL,
  component_order = NULL,
  main_traffic = "Risk of Bias (Study Level)",
  main_aggregate = "Risk of Bias by Component (%)",
  low_col = "#2E8B57",
  unclear_col = "#F0C419",
  high_col = "#C0392B",
  cex_axis = 0.85,
  cex_main = 1,
  study_legend_position = "top",
  aggregate_legend_position = "top",
  study_legend_title = NULL,
  aggregate_legend_title = NULL,
  legend_inset = c(0, -0.13),
  main_traffic_adj = 0.5,
  main_aggregate_adj = 0.5,
  plot = c("both", "study", "aggregate"),
  separate_plots = FALSE,
  aggregate_horizontal = FALSE
)

Arguments

data

A data frame in long format.

study

Character string naming the study ID column.

component

Character string naming the risk-of-bias component/domain column.

decision

Character string naming the judgment column. Values are matched to \code"Low", \code"Unclear", and \code"High" (case-insensitive). Common misspellings such as \code"uncler" are accepted.

study_order

Optional character vector with custom study order.

component_order

Optional character vector with custom component order.

main_traffic

Title for the traffic-light panel.

main_aggregate

Title for the aggregate stacked-bar panel.

low_col

Color used for low risk.

unclear_col

Color used for unclear risk.

high_col

Color used for high risk.

cex_axis

Axis text scaling.

cex_main

Main title scaling.

study_legend_position

Legend position for the study panel. Use "none" to suppress.

aggregate_legend_position

Legend position for the aggregate panel. Use "none" to suppress.

study_legend_title

Optional legend title for the study panel.

aggregate_legend_title

Optional legend title for the aggregate panel.

legend_inset

Numeric legend inset passed to legend.

main_traffic_adj

Horizontal title alignment in [0, 1] for the study panel title.

main_aggregate_adj

Horizontal title alignment in [0, 1] for the aggregate panel title.

plot

Which panel(s) to draw: \code"both", \code"study", or \code"aggregate".

separate_plots

Logical. If \codeTRUE and \codeplot = "both", the study-level and aggregate plots are drawn on separate plot pages.

aggregate_horizontal

Logical. If \codeTRUE, the aggregate percentages are drawn as horizontal stacked bars.

Value

Invisibly returns a list containing: \describe \itemdecision_matrixStudy x component matrix with values \code"Low", \code"Unclear", or \code"High". \itemcountsComponent x decision count matrix. \itempercentagesComponent x decision percentage matrix (rows sum to 100).

Details

Input data must be in long format with one row per study-component judgment.

Examples

rob_dat <- data.frame(
  study = rep(paste0("Study_", 1:5), each = 4),
  component = rep(c("Randomization", "Allocation", "Blinding", "Attrition"), 5),
  decision = c(
    "Low", "Low", "Unclear", "High",
    "Low", "Unclear", "Unclear", "High",
    "High", "High", "Unclear", "Low",
    "Low", "Low", "Low", "Low",
    "Uncler", "Low", "High", "Unclear"
  ),
  stringsAsFactors = FALSE
)

risk_of_bias_plot(
  data = rob_dat,
  study = "study",
  component = "component",
  decision = "decision",
  plot = "aggregate",
  aggregate_horizontal = TRUE
)