forestplot2 {reportRmd} | R Documentation |
Create a forest plot using ggplot2
Description
This function will accept a log or logistic regression fit from glm or geeglm, and display the OR or RR for each variable on the appropriate log scale.
Usage
forestplot2(
model,
conf.level = 0.95,
orderByRisk = TRUE,
colours = "default",
showEst = TRUE,
rmRef = FALSE,
logScale = getOption("reportRmd.logScale", TRUE),
nxTicks = 5
)
Arguments
model |
an object output from the glm or geeglm function, must be from a logistic regression |
conf.level |
controls the width of the confidence interval |
orderByRisk |
logical, should the plot be ordered by risk |
colours |
can specify colours for risks less than, 1 and greater than 1.0. Default is red, black, green |
showEst |
logical, should the risks be displayed on the plot in text |
rmRef |
logical, should the reference levels be removed for the plot? |
logScale |
logical, should OR/RR be shown on log scale, defaults to TRUE, or reportRmd.logScale if set. See https://doi.org/10.1093/aje/kwr156 for why you may prefer a linear scale. |
nxTicks |
Number of tick marks supplied to the log_breaks function to produce |
Value
a plot object
Examples
data("pembrolizumab")
glm_fit = glm(orr~change_ctdna_group+sex+age+l_size,
data=pembrolizumab,family = 'binomial')
forestplot2(glm_fit)