produces forest plots

fplot(
  dat,
  nrows = 1,
  ncols = NA,
  nns = NA,
  lheights = c(0.1, 1, 0.05),
  lwidths = NA,
  y.at = NA,
  font = NA,
  arrow = TRUE,
  arrow_length = 0.05,
  arrow_angle = 30,
  cap_length = 0,
  shift_label_col = 0,
  center_label_col = NA,
  shift_textbeta_col = 0,
  shift_ymax = 0,
  shift_ymin = 0,
  xlab = NA,
  xlab_text = NA,
  xlim = NA,
  xlab_cex = 0.6,
  xlab_line = 0,
  tck = -0.04,
  shift_xaxis = 0,
  xtitle = NA,
  lwd = 1,
  pcol = rgb(0.1, 0.1, 0.1, 0.2),
  lscale = FALSE,
  ps = NA,
  header = NA,
  ref = list(x = NA, extend = 0, lty = 2, col = "grey50", lwd = lwd),
  bottomline = NA,
  headline = NA,
  headline_pos = c(0, 1),
  beta2 = NULL,
  xlab2 = NA,
  xlab_text2 = NA,
  xlim2 = NA,
  xtitle2 = NA,
  ...
)

Arguments

dat

data frame with variables called vlabel (labels), nx with x=1,2,... (num or chr columns with strings, e.g. number of observations or descriptives), beta, beta_lci, beta_uci (num columns with point estimates and confidence interval) optionally beta_format (num or chr column with formatted text to be printed along forest, generated from beta if not given) px with x=1,2,.. (num or chr columns with p-value(s))

nrows

number of rows, setting for layout, default is 1

ncols

number of columns, setting for layout, typically derived from the data

nns

number of n columns, derived from data if not given

lheights

lheights: relative height of rows, length is typically 3 (header, data ,footer)

lwidths

lwidths: relative width of columns, length correpsonds to columns in forest plus 2 (left and right margin)

y.at

position of lines, 1:nrow(dat) by default

font

font for variable vlabel, length has to correspond to rows of dat, default is rep(1,nrow(dat))

arrow

logical, whether to use arrows if xlim does not include confidence interval limits

arrow_length

length of the edges of the arrow head (in inches)

arrow_angle

angle from the shaft of the arrow to the edge of the arrow head

cap_length

length of the confidence interval cap, 0 if none

shift_label_col

inset of labels in the first column, default is 0

center_label_col

centering of label in first column

shift_textbeta_col

inset of formatted effects (beta_format)

shift_ymax

down-shift of maximal y-value, smaller space to top

shift_ymin

up-shift of minimal y-value, smaller space to bottom

xlab

position of labels for x-axis, derived from beta by default

xlab_text

text at the labels, derived from beta by default

xlim

limits for x-axis in forest plots, derived from beta by default

xlab_cex

size of x-axis labels (not title)

xlab_line

position of x-axis label (not title)

tck

x-axis tick length

shift_xaxis

shift position of x-axis

xtitle

x axis title and format, list with x (xpos), y (ypos), textr and textl (text at the right/left side), cex (text size)

lwd

line widths

pcol

color if symbols are used, not active

lscale

logicial, beta given on log scale, use exp to format beta, default is FALSE

ps

points for plot, list with pch, cex, and col

header

for table, either a character vector or a list with any of x (vector with xpos), y (single y-position), text (character vector with labels), cex (text size), the list can be >1 to define more than one header line

ref

reference line, list with x (xposition), extend (extension on top), lty (line type), col (line color), lwd (line width)

bottomline

line at the bottom if not NA

headline

line for header if not NA, 1 for one line at the bottom, 2 for a line at the bottom and top

headline_pos

vector with position of lower and upper headline (if applicable), default c(0,1)

beta2

if not NULL a second forest is generated, needs variables beta2, beta_lci2 and beta_uci2 in dat

xlab2

see xlab for 2nd forest

xlab_text2

see xlab_text for 2nd forest

xlim2

see xlim for 2nd forest

xtitle2

see xtitle for 2nd forest

...

options passed to ff_ci for formatting the effects (if beta_format not given)

Value

forest plot

Details

required input is a data frame with a column called vlabel, beta, beta_lci and beta_uci.

Examples

data(forplotdata)
# Minimal example
 fplot(dat=forplotdata[,c("vlabel","beta","beta_lci","beta_uci")])

# Standard example
fplot(dat=forplotdata)


# Set widths and heights
lwidths<-c(0.05,0.5,0.2,0.8,0.2,0.8,1.2,1.2,0.5,0.05)
lheights<-c(0.14,1,0.08)
fplot(dat=forplotdata,lwidths=lwidths,lheights=lheights)



# Include header:
header<-c("","Group1\nN","Group0\nmean (sd)","Group2\nN","Group2\nmean (sd)",
"Mean difference\n95% CI","","P-value")
fplot(dat=forplotdata,lwidths=lwidths,lheights=lheights,header=header)


header<-list(list(y=0.7,
  text=c("Group1","Group2","Mean difference (95% CI)","P-value"),
  x=c(0.10,0.32,0.7,0.98)),
  list(y=0.3,text=c("N","mean (sd)","N","mean (sd)"),
  x=c(0.07,0.18,0.28,0.38)))
fplot(dat=forplotdata,header=header,lwidths=lwidths,lheights=lheights)


# Reference line and xlim
xtitle<-list(x=0.86,y=0.2,textl="Group 1 better  ",textr="  Group 2 better")
fplot(dat=forplotdata,header=header,lwidths=lwidths,lheights=lheights,
xtitle=xtitle,ref=list(x=0),xlim=c(-1,0.5))


# Shift x-axis, labels and title
xtitle<-list(x=0.86,y=0.6,textl="Group 1 better  ",textr="  Group 2 better")
fplot(dat=forplotdata,header=header,lwidths=lwidths,lheights=lheights,
ref=list(x=0,col=2,extend=2),
xtitle=xtitle,xlim=c(-1,0.5),shift_xaxis=0.3,xlab_line=-0.8)


# Lines at header and bottom
fplot(dat=forplotdata,header=header,lwidths=lwidths,lheights=lheights,
   ref=list(x=0,col=2,extend=2),
  xtitle=xtitle,xlim=c(-1,0.5),shift_xaxis=0.3,xlab_line=-0.8,
  headline=2,bottomline=1)