Skip to contents

forestplot function

Usage

forestplot(
  df,
  name = name,
  estimate = estimate,
  se = se,
  pvalue = NULL,
  label_column = NULL,
  label_width = 1,
  colour = NULL,
  shape = NULL,
  logodds = FALSE,
  psignif = 0.05,
  ci = 0.95,
  ...
)

Arguments

df

A data frame with the data to plot. It must contain at least three variables, a character column with the names to be displayed on the y-axis (see parameter name), a numeric column with the value (or the log of the value) to display (see parameter estimate) and a numeric value with the corresponding standard errors (see parameter se). It may contain additional columns, e.g. the corresponding p-values (see parameter pvalue) in which case, in conjuction with the threshold given in psignif, the non-significant results will be displayed as hollow points. Other variables may be used as ggplot2::aesthetics to define the colour and the shape of the points to be plotted.

name

the variable in df that contains the y-axis names. This argument is automatically quoted and evaluated in the context of the df data frame.

estimate

the variable in df that contains the values (or log of values) to be displayed. This argument is automatically quoted and evaluated in the context of the df data frame.

se

the variable in the df data frame that contains the standard error values. This argument is automatically quoted and evaluated in the context of the df data frame.

pvalue

the variable in df that contains the p-values. Defaults to NULL. When explicitly defined, in conjuction with the p-value threshold provided in the psignif, the non-significant entries will be drawn as hollow points. This argument is automatically quoted and evaluated in the context of the df data frame.

label_column

Optional variable in df that contains the labels to display. If provided, a separate label plot will be generated and combined with the forest plot.

label_width

A numeric value to specify the relative width of the label plot in the combined output. Default is 1.

colour

the variable in df by which to colour the different groups of points.

shape

the variable in df by which to shape the different groups of points.

logodds

logical (defaults to FALSE) specifying whether the estimate parameter should be treated as log odds/hazards ratio (TRUE) or not (FALSE). When logodds = TRUE the estimates and corresponding confidence intervals will be exponentiated and a log scale will be used for the x-axis.

psignif

numeric, defaults to 0.05. The p-value threshold for statistical significance. Entries with larger than psignif will be drawn with a hollow point.

ci

A number between 0 and 1 (defaults to 0.95) indicating the type of confidence interval to be drawn.

...

ggplot2 graphical parameters such as title, ylab, xlab, xtickbreaks etc. to be passed along.

Value

A ggplot or cowplot object.