Learn R Programming

jarbes (version 2.4.2)

plot_data: Plot Data Function

Description

This function plots the treatment effect (TE) against specified covariates or creates a forest plot of treatment effects, arranging up to four plots in a grid.

Usage

plot_data(
  data,
  formula = ~1,
  group = NULL,
  group.colors = NULL,
  study.label = NULL,
  x.lab = NULL,
  y.lab = "TE",
  title.plot = NULL,
  errbar.width = 0.25,
  label.size = 6,
  forest.color = "blue",
  forest.shape = 19,
  forest.size = 3,
  xlim = NULL,
  ylim = NULL,
  ...
)

Value

A `gridExtra` plot object or a single `ggplot` object.

Arguments

data

A data frame with columns `TE`, `seTE`, and the covariates.

formula

A one-sided formula (e.g., `~ x1 + x2`) for the x-axis variables. If not provided or `~1`, a forest plot is generated.

group

A character string specifying the name of the column in `data` to use for grouping the points (e.g., by color/fill) in covariate plots. Defaults to `NULL`. This parameter is ignored for forest plots.

group.colors

A character vector specifying colors for the groups (when `group` is used). Can be a named vector where names match the levels of the grouping variable. Defaults to `NULL`, which uses ggplot2's default discrete colors.

study.label

A character string specifying the name of the column in `data` that contains the study labels for the forest plot. If `NULL`, default labels ("Study 1", "Study 2", etc.) are created.

x.lab

A character vector for x-axis labels. Defaults to variable names.

y.lab

Text for the y-axis label. Defaults to "TE" or "Study" for forest plots.

title.plot

Text for the plot title. Defaults to `NULL`.

errbar.width

The width of the error bars for regular plots. Defaults to `0.25`.

label.size

A numeric value for the font size of the study labels in the forest plot. Defaults to `6`.

forest.color

The color of the points and error bars in the forest plot. Defaults to "blue".

forest.shape

The shape of the points in the forest plot. Defaults to `19` (filled circle).

forest.size

The size of the points in the forest plot. Defaults to `3`.

xlim

A numeric vector of length 2 for the x-axis limits.

ylim

A numeric vector of length 2 for the y-axis limits.

...

Additional arguments passed to `geom_point()`.