Learn R Programming

contourforest (version 0.2.0)

forest_prev: Prevalence Forest Plot

Description

Generates a forest plot for prevalence data with study-level estimates, confidence intervals, weights, and pooled prevalence. Supports contour shading for prevalence ranges.

Usage

forest_prev(
  dat,
  events_col = "events",
  n_col = "n",
  study_col = "Study",
  xlab = "Prevalence (%)",
  title = "Prevalence Forest Plot",
  xlim = c(-25, 140),
  diamond.col = "red",
  study.col = "blue",
  CI.col = "blue",
  square.size = 7,
  text_size = 3.5,
  xpos_study = -12,
  xpos_events = -5,
  xpos_prev = 50,
  xpos_weight = 55,
  xpos_pooled_label = NULL,
  xpos_pooled_value = NULL,
  contour_breaks = c(0, 5, 10, 25, 50),
  contour_colors = c("gray90", "gray70", "gray50", "gray30"),
  legend_title = "Prevalence"
)

Value

A ggplot object representing the prevalence forest plot.

Arguments

dat

A data frame containing study-level prevalence data.

events_col

Name of the column containing the number of events.

n_col

Name of the column containing the total sample size.

study_col

Name of the column with study labels.

xlab

Label for the x-axis. Default is "Prevalence (%)".

title

Plot title.

xlim

Numeric vector of length 2 specifying x-axis limits.

diamond.col

Color of the pooled prevalence diamond.

study.col

Color of the study points.

CI.col

Color of the confidence intervals.

square.size

Size of the study-level squares.

text_size

Base text size for labels and annotations.

xpos_study

X-axis position for study labels.

xpos_events

X-axis position for event counts.

xpos_prev

X-axis position for prevalence values.

xpos_weight

X-axis position for study weights.

xpos_pooled_label

X-axis position for pooled label (optional; defaults relative to pooled prevalence).

xpos_pooled_value

X-axis position for pooled value (optional; defaults relative to pooled prevalence).

contour_breaks

Numeric vector defining contour thresholds.

contour_colors

Colors for contour shading.

legend_title

Title for the contour legend.

Examples

Run this code
dat <- data.frame(
  Study = c("Bazargani et al. 2015", "Nandhra et al. 2015", "Rai 2015", "Romano et al. 2011"),
  events = c(25, 109, 24, 9),
  n = c(454, 757, 380, 100)
)

forest_prev(
  dat = dat,
  title = "Prevalence Forest Plot",
  xlim = c(-25, 80),
  xpos_study = -12,
  xpos_events = -5,
  xpos_prev = 40,
  xpos_weight = 52,
  contour_breaks = c(0,5,10,25,35),
  contour_colors = c("gray90","gray70","gray50","gray30"),
  legend_title = "Prevalence (%)"
)

Run the code above in your browser using DataLab