Produces forest plots using 'ggplot2' from models produced by functions such as stats::lm(), stats::glm() and survival::coxph().
This is an R package to generate forest plots of the coefficients of models produced by
The main function is
forest_model, with a helper function
default_forest_panels to produce the necessary
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
Development takes place on the github repository https://github.com/NikNakk/forestmodel/.
forest_modelwhich meant that non-synatic variable names (e.g. with spaces in the title) were dropped from the plot.
panel_forest_plotthat produced warnings.
coxphmodels with a single predictor (thanks @vjd) for identifying the bug)
coxphmodels that used special functions.
graphics::axisTicksfor break calculation.
person_timevariables to data for display when using a
forest_rmafunction to produce forest plots from output of