Forest plots in R (ggplot) with side table

November 6, 2012

(This article was first published on Matt's Stats n stuff » R, and kindly contributed to R-bloggers)

A friend asked me to help with a forest plot recently. After chatting about what she wanted the end result to look like, this is what I came up with.

grid.arrange(data_table, p, ncol=2)
## Warning: Removed 1 rows containing missing values (geom_point).

Some other options for forest plots included this:

From Abhijit blog. But I figured I’d start a fresh, and I’d already borrowed some code of Abhijits in the past for a survival curve.

The package rmeta offers two different versions. One with forestplot like so:

And one with metaplot like so:

Ultimately the two would be used for different purposes, and these examples shown are straight from the manual for rmeta.

It wasn’t too much work to create ‘another’ custom option to get what my friend wanted, so thought I’d share the code for anyone else interest. There was a little bit of ‘misdirection’ for lack of a better term to get it across the line, and I’m sure elements of this are sloppy. You can access the code on my github.

I wrote this post in RStudio using the R Markdown language and then knitr to turn in into markdown (.md), and then pandoc to turn it into html. The original file is available here on github.

system(“pandoc -s -o forest_plot.html”)

To leave a comment for the author, please follow the link and comment on their blog: Matt's Stats n stuff » R. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)