fplot.Rd
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,
...
)
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))
number of rows, setting for layout, default is 1
number of columns, setting for layout, typically derived from the data
number of n columns, derived from data if not given
lheights: relative height of rows, length is typically 3 (header, data ,footer)
lwidths: relative width of columns, length correpsonds to columns in forest plus 2 (left and right margin)
position of lines, 1:nrow(dat) by default
font for variable vlabel, length has to correspond to rows of dat, default is rep(1,nrow(dat))
logical, whether to use arrows if xlim does not include confidence interval limits
length of the edges of the arrow head (in inches)
angle from the shaft of the arrow to the edge of the arrow head
length of the confidence interval cap, 0 if none
inset of labels in the first column, default is 0
centering of label in first column
inset of formatted effects (beta_format)
down-shift of maximal y-value, smaller space to top
up-shift of minimal y-value, smaller space to bottom
position of labels for x-axis, derived from beta by default
text at the labels, derived from beta by default
limits for x-axis in forest plots, derived from beta by default
size of x-axis labels (not title)
position of x-axis label (not title)
x-axis tick length
shift position of x-axis
x axis title and format, list with x (xpos), y (ypos), textr and textl (text at the right/left side), cex (text size)
line widths
color if symbols are used, not active
logicial, beta given on log scale, use exp to format beta, default is FALSE
points for plot, list with pch, cex, and col
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
reference line, list with x (xposition), extend (extension on top), lty (line type), col (line color), lwd (line width)
line at the bottom if not NA
line for header if not NA, 1 for one line at the bottom, 2 for a line at the bottom and top
vector with position of lower and upper headline (if applicable), default c(0,1)
if not NULL a second forest is generated, needs variables beta2, beta_lci2 and beta_uci2 in dat
see xlab for 2nd forest
see xlab_text for 2nd forest
see xlim for 2nd forest
see xtitle for 2nd forest
options passed to ff_ci for formatting the effects (if beta_format not given)
forest plot
required input is a data frame with a column called vlabel, beta, beta_lci and beta_uci.
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)