Learn R Programming

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.

Installation

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/.

Installation

You can install the released version of forestmodel from CRAN with:

install.packages("forestmodel")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("NikNakk/forestmodel")

Example

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)))

Specifying the covariates to show:

print(forest_model(coxph(Surv(time, status) ~ ., pretty_lung), 
                   covariates = c("Age", "Sex")))

Copy Link

Version

Install

install.packages('forestmodel')

Monthly Downloads

1,891

Version

0.6.2

License

GPL-2

Maintainer

Last Published

July 19th, 2020

Functions in forestmodel (0.6.2)

theme_forest

Default forest theme
forest_breaks

Calculate default breaks for limits
forest_rma

Generate a forest plot from a meta-analysis
panel_forest_plot

Plot a forest plot with panels of text
forest_model

Produce a forest plot based on a regression model
forest_model_format_options

Create format options for forest_model
forest_panels

Generate panels for forest plots
default_forest_panels

Default panels for forest_model
forest_panel

Create definition of a panel for forest_model