forestplot: Create a forestplot

Description Usage Arguments Examples

Description

Forest plots are commonly used in clinical research to illustrate e.g. odds ratios or hazard ratios with 95 percent confidence intervals. The present function will create a forestplot. It assumes the input to be in a dataframe, where there is one column each for hazard ratio, upper confidence interval, lower confidence interval, text to be written to the left of the plot and (optional) text to the right of the plot.

Usage

1
2
3
forestplot(f_data, hr, lci, uci, ltext, rtext = NULL,
  axis_text = "Hazard ratio", point_size = 4, point_color = "black",
  text_size = 5, ref_line = 1, right_offset = 0.4)

Arguments

f_data

a dataframe containing information for the forestplot (arranged as outlined above, and as demonstrated below)

hr

which column contains hazard ratio, or odds ratio, etc. ?

lci

which column contains lower confidence interval?

uci

which column contains upper confidence interval?

ltext

which column contains the text that should be put on the left side of the plot?

rtext

which column contains the text that should be put on the right side of the plot?

axis_text

what should the axis label be? By default: Hazard ratio.

point_size

size of the points in the plot

point_color

color of the points in the plot

text_size

size of the text in the plot

ref_line

where should the reference line be drawn. By default: 1. Enter value NULL to skip putting a reference line in the plot.

right_offset

a number that controls the offset of the right text column. Its optimal value depends of the size of the plot, etc. Might need some tweaking of this value to make the plot look perfect!

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Create some test data
hr <- seq(0.80, 1.1, by = 0.05)
lci <- hr - 0.1
uci <- hr + 0.1
left_text<- paste0("Left text no ", 1:7)
right_text <- paste0("Right text no ", 1:7)
forest_data <- data.frame(left_text,lci,hr,uci,right_text)

# Basic forest plot
forestplot(forest_data, hr, lci, uci, left_text)

# With right text column
forestplot(forest_data, hr, lci, uci, left_text, right_text, point_color = "purple")

# Combined with hrci function
forestplot(forest_data, hr, lci, uci, left_text, hrci(forest_data), point_color = "darkgreen")

dlindholm/doctoR documentation built on May 15, 2019, 9:18 a.m.