forestplot: Create a forest plot and table of coefficients and stats from...

View source: R/knitr_utils.R

forestplotR Documentation

Create a forest plot and table of coefficients and stats from one or more regression models.

Description

Create a forest plot and table of coefficients and stats from one or more regression models.

Usage

forestplot(
  ...,
  modelnames = NULL,
  varnames = NULL,
  stats = NULL,
  odds.ratio = F,
  breaks = NULL,
  intercept = T,
  facet = T,
  dodgewidth = 0.3,
  linewidth = 1,
  size = 1,
  draw = T,
  sig = 3,
  ddf = NULL
)

Arguments

...

One or more model objects.

modelnames

A character vector of names to label each plot and table column.

varnames

A named character vector. Each element is a human friendly version of the variable name, and each name is the original variable name.

odds.ratio

If TRUE, apply exponential transform to coefficients and omit intercept.

breaks

An optional vector of breaks for the plot x-axis.

intercept

If TRUE, include the intercept in the table and plot; otherwise omit.

facet

If TRUE, display models in different facets. Otherwise, distinguish by color.

dodgewidth

For position_dodge(). Default = 0.3.

draw

If TRUE draw the plot; otherwise return the data. Default TRUE

sig

The number of significant digits for the table.

Value

A ggplot object.

Examples

data(mtcars)
m1 <- lm(mpg ~ hp, mtcars)
m2 <- lm(mpg ~ wt, mtcars)
mnms <- c('MPG vs HP', 'MPG vs Weight')
vnms <- c(mpg='Miles per gallon', hp='Horsepower', wt='Weight')
forestplot(m1, m2, modelnames=mnms, varnames=vnms)

grasshoppermouse/hagenutils documentation built on Dec. 6, 2024, 8:31 p.m.