Removing upper and lower CI from annotations in Metafor

299 Views Asked by At

I'm using the Metafor package to plot forest plots and I was wondering if anyone knew a way to omit the upper and lower CIs from the text annotations, for example where one group is a reference and outcome is fixed at 1.

Here is an example:

library(metafor)

par(mar=c(5,4,1,2))

forest(x     = c(1, 0.9, 1.1),
       ci.ub = c(1, 0.98, 1.18),
       ci.lb = c(1, 0.82, 1.02),
       refline = 1)

enter image description here

I would like to remove [1.00, 1.00] from the Study 1 row only, leaving just 1.00.

The only possibility I can think of would be to plot something in white over the top of these, but this would be fiddly, and I have a large complex plot with many groups.

1

There are 1 best solutions below

2
On

You could play around with the graph produced by the call to the forest function, removing the annotation on the right-hand side with the option annotate = FALSE. After that, you could opt to add your own text with the function text (with limited possibilities) like in the code below.

library(metafor)
par(mar=c(5,4,1,2))

forest(x     = c(1, 0.9, 1.1),
       ci.ub = c(1, 0.98, 1.18),
       ci.lb = c(1, 0.82, 1.02),
       refline = 1,
       annotate = FALSE,   ### added
       )

text(x = c(1.25, 1.25, 1.25), y = c(3, 2, 1), 
     label=c("1.00", "0.90", "1.10"))

This yields the following graph:

enter image description here