Forest Plots from Regression Models

Produces forest plots using 'ggplot2' from models produced by functions such as stats::lm(), stats::glm() and survival::coxph().


forestmodel

This is an R package to generate forest plots of the coefficients of models produced by lm, glm, survival::coxph, etc.

The main function is forest_model, with a helper function default_forest_panels to produce the necessary panels data.frame.

library("forestmodel")
library("survival")
library("dplyr")
pretty_lung <- lung %>%
  transmute(time,
            status,
            Age = age,
            Sex = factor(sex, labels = c("Male", "Female")),
            ECOG = factor(lung$ph.ecog),
            `Meal Cal` = meal.cal)
 
print(forest_model(coxph(Surv(time, status) ~ ., pretty_lung)))

The package can be installed using install.packages. It needs Hadley Wickham's broom, dplyr, gpplot2 and lazyeval packages.

Development takes place on the github repository https://github.com/NikNakk/forestmodel/.

News

  • Fixed problem with coxph models that used special functions.
  • Changed from forest_breaks to graphics::axisTicks for break calculation.
  • Added n_events and person_time variables to data for display when using a coxph model
  • Now handles logical covariates appropriately
  • Tweaks to break and limit calculation
  • Added option (set as default) to recalcluate panel widths
  • Added function to make custom panels easier to generate (forest_panels)
  • Tidied up parameters to make them more consistent between functions
  • Updated panel object to be a list of lists for greater flexibility
  • Added forest_rma function to produce forest plots from output of metafor::rma
  • Initial release

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("forestmodel")

0.4.3 by Nick Kennedy, 5 months ago


Browse source code at https://github.com/cran/forestmodel


Authors: Nick Kennedy <r@nick-kennedy.com>


Documentation:   PDF Manual  


Task views: Meta-Analysis


GPL-2 license


Imports dplyr, broom, lazyeval

Depends on ggplot2

Suggests survival, metafor


See at CRAN