Creates a forest plot with ggplot
make_forest_plot(
panels,
row.labels = NULL,
row.labels.levels = c("heading1", "heading2", "heading3"),
rows = NULL,
exponentiate = TRUE,
logscale = exponentiate,
panel.names = NULL,
panel.headings = panel.names,
col.key = "key",
col.estimate = "estimate",
col.stderr = "stderr",
col.lci = NULL,
col.uci = NULL,
col.left = NULL,
col.right = NULL,
col.right.parse = FALSE,
col.left.heading = "",
col.right.heading = "HR (95% CI)",
col.left.pos = NULL,
col.right.pos = NULL,
col.left.hjust = 1,
col.right.hjust = 0,
col.heading.space = 0,
estcolumn = TRUE,
col.keep = NULL,
ci.delim = ", ",
digits = 2,
title = "",
xlab = "HR (95% CI)",
xlim = NULL,
xticks = NULL,
nullval = NULL,
blankrows = c(1, 1, 0, 0),
col.diamond = NULL,
diamond = NULL,
col.bold = NULL,
bold.labels = NULL,
scalepoints = FALSE,
minse = NULL,
pointsize = 3,
shape = NULL,
plotcolour = "black",
colour = NULL,
cicolour = colour,
fill = NULL,
ciunder = NULL,
addtext = NULL,
left.space = NULL,
right.space = NULL,
mid.space = unit(5, "mm"),
plot.margin = margin(8, 8, 8, 8, "mm"),
panel.width = NULL,
base_size = 11,
base_line_size = base_size/22,
stroke = 0,
printplot = TRUE,
showcode = TRUE,
addcode = NULL,
addaes = NULL,
addarg = NULL,
envir = NULL,
cols = panels,
headings = NULL,
colnames = NULL,
colheadings = colnames,
boldheadings = NULL,
heading.space = NULL,
panel.space = NULL,
label.space = NULL,
plot.space = NULL,
col.right.space = NULL,
col.left.space = NULL,
margin = NULL,
units = NULL
)
A list of data frames. These should include columns or point estimates, and standard errors or confidence interval limits. If you specify a row.labels data frame, then they must also all contain a key column with the same name (which can be specified by col.key).
A data frame that contains the labels to be used for the rows of the plot. Use NA if a lower level heading is not required for a given row.
A character vector up to length 3. The names of columns in row.labels to use as headings/subheadings/labels for labelling rows. (Default: c("heading1", "heading2", "heading3"))
A character vector. The top level labels of rows to be included in the plot.
Exponentiate estimates (and CIs) before plotting. (Default: TRUE)
Use log scale on the axis, and add a line at null effect. (Default: exponentiate)
A character vector. The names to be used for each forest plot panel. If none provided, then they will be numbered 1, 2, 3 ...
Titles to be placed above each forest plot. (Default: panel.names)
Name of column that links the results given in each data frame provided in panels and the labels given in row.labels.
If row.labels data frame is not given, then this column will be used as row labels.
(Default: "key")
Name of column that provides point estimates. (Default: "estimate")
Name of column that provides standard errors. (Default: "stderr")
Name of column that provides lower limit of confidence intervals.
Name of column that provides upper limit of confidence intervals.
Names of columns to be printed to the left of the plot.
Names of columns to be printed to the right of the plot.
A logical vector, the same length as col.right (+ 1 if estcolumn = TRUE). Should the contents of the columns be parsed into expressions. (Default: All FALSE, except estcolumn.)
A character vector of titles for col.left columns. (Default: "")
A character vector of titles for the column of estimates (if estcolumn = TRUE) and col.right columns. (Default: "HR (95% CI)")
A unit vector to position col.right columns.
A unit vector to position col.right columns.
A numeric vector. The horizontal justification of col.left columns. (Default: 1)
A numeric vector. The horizontal justification of col.right columns. (Default: 0)
Position of the titles given by col.left.heading and col.right.heading. Increase to move them up. (Default: 0)
Include column of estimates and confidence intervals to the right of each plot. (Default: TRUE)
Names of additional columns to be kept in returned data frame.
Character string to separate lower and upper limits of confidence interval. (Default: ", ")
Number of digits after decimal point to show for estimates and confidence intervals. (Default: 2)
Title to appear at the top of the plot.
Label to appear below the x-axis. (Default: "HR (95% CI)")
A numeric vector. The limits of the x axis.
A numeric vector. The tick points of the x axis.
Add a vertical reference line at this value. (If logscale == TRUE then by default it will be added at 1, but use NA not to plot this line.)
A numeric vector of length 4 specifying the number of blank rows after a heading1, at the end of a heading1 'section', after a heading2, and at the end of a heading2 'section. (Default: c(1, 1, 0, 0))
Plot estimates and CIs as diamonds. Name of a column of logical values.
Alternative to col.diamond. A character vectors identify the rows (using the key values) for which the estimate and CI should be plotted using a diamond.
Plot text as bold. Name of a column of logical values.
A character vector identifying row labels (using key values) which should additionally be bold. (Default: NULL)
Should the points be scaled by inverse of the standard error? (Default: FALSE)
Minimum standard error to use when scaling point size. (Default will use minimum in the data.)
The (largest) size of box to use for plotting point estimates. (Default: 3)
Shape of points. An integer, or name of a column of integers. (Default will use shape 22 - squares with fill.)
Colour for all parts of the plot. (Default: "black")
Colour of points. Name of a colour, or name of a column of colour names. (Default will use plotcolour.)
Colour of CI lines. Colour of CI lines. Name of a colour, or name of a column of colour names. (Default will use plotcolour.)
Fill colour of points. Fill colour of points. Name of a colour, or name of a column of colour names. (Default will use plotcolour.)
Plot CI lines before points. A logical value, or name of a column of logical values. (Default will plot CI lines after points.)
A list of data frames. List must be the same length as panels. Data frames should contain a column with the name specified in col.key, and one or more of:
1. a column named 'text' containing character strings
2. columns named 'het_dof', 'het_stat', and 'het_p' containing character strings
3. columns names 'trend_stat' and 'trend_p' containing character strings
The character strings, heterogeneity test, and trend test results will be plotted in the column of estimates and CIs, below the row with the key given in the col.key column.
Size of gap to leave to the left of panels. (Default: 1 + 2*length(col.left))
Size of gap to leave to the right of panels. (Default: 5 + 2*length(col.right))
Size of additional gap to leave between panels. (Default: unit(5, "mm"))
Plot margin, given as margin(top, right, bottom, left, units). (Default: margin(8, 8, 8, 8, "mm"))
Panel width to assume and apply different formatting to narrow CIs. Unit is "mm".
base font size, given in pts.
base size for line elements
Size of outline of shapes. (Default: 0)
Print the plot. (Default: TRUE)
Show the ggplot2 code to generate the plot in RStudio 'Viewer' pane. (Default: TRUE)
A character vector of code to add to the generated code. The first element should be a regular expression. The remaining elements are added to the generated code just before the first match of a line (trimmed of whitespace) with the regular expression. (Default: NULL)
Specify additional aesthetics for some ggplot layers.
Specify additional arguments for some ggplot layers.
Environment in which to evaluate the plot code. May be useful when calling this function inside another function.
DEPRECATED.
DEPRECATED.
DEPRECATED.
DEPRECATED.
DEPRECATED.
DEPRECATED. Even older method for specifying spacing.
DEPRECATED. Old method for specifying spacing.
DEPRECATED. Old method for specifying spacing.
DEPRECATED. Even older method for specifying spacing.
DEPRACTED
DEPRACTED
DEPRECATED. Old method for specifying margins.
DEPRECATED
A list:
the plot
ggplot2 code to generate the plot
The function returns the plot and ggplot2 code to create the plot. In RStudio, the ggplot2 code will be shown in the viewer.