Nice Angry post about R’s quirks

# Monthly Archives: January 2013

# My Fight with forestplot: Now forestplot2

So a collaborator of mine (let’s call him Joe) wanted side by side forestplots to compare the odds ratios for the treatment effect in our current study compared to a published study using data from a PDF.

After using readPDF from the tm package in R to get the data in, without having to type it in by hand (at an attempt to make this reproducible), I started in on the forestplot. I used the rmeta package after some googling and found it had a simple-enough syntax and flexible enough input so that I could use non-standard odds ratio estimators (may use some causal estimators) if needed.

I’ve found that with many of my collaborators, tweaking and customization is the rule, not the exception. This was no different. First off, Joe wanted some boxes to have different colors, and wanted the text big since it was going into a powerpoint slide. Hacking through this and other features, I added an option to pass a vector of box colors, line colors, font sizes, graph width, changing rectangles to circles, changing the column gap size, defining the range of the x-axis, and an “add” flag so that you can call this function without plot.new() getting invoked.

Here is the code (posted using Gist from this post:

Also, Joe wanted to have side-by-side forestplots. Using par(mfrow=c(1,2)) would be the solution here, but forestplot uses grid viewports that don’t support this. Thinking about how this may work best, I decided to use LaTeX, the onimage package (see stackexhange) to put a box around some odds ratios, and the preview package to simply get an image and not a whole document. I did some trimming and such:

Here is the LaTeX:

and the final image is here

Edit: Found this post https://stat.ethz.ch/pipermail/r-help/2010-April/235849.html that did something similar with respect to circles