Search code examples
rmetafor

Changing "." to "-" in the summary column of a forest plot


I am trying to adjust my forest plot according to a journals guidelines. One of them is changing all "." to "-", e.g. "0.43" to "0-45". Weird, I know. Is there a possibility to do that for the summary column of the forest plot (the most right hand side in this case, see the example code). I feel like it should be fairly easy, but I still have not figured it out.

here is an example code:

library(metafor)
 
### copy BCG vaccine meta-analysis data into 'dat'
dat <- dat.bcg
 
### calculate log risk ratios and corresponding sampling variances (and use
### the 'slab' argument to store study labels as part of the data frame)
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat,
              slab=paste(author, year, sep=", "))
 
### fit random-effects model
res <- rma(yi, vi, data=dat)
 
### forest plot with extra annotations
forest(res, atransf=exp, at=log(c(0.05, 0.25, 1, 4)), xlim=c(-16,6),
       ilab=cbind(tpos, tneg, cpos, cneg), ilab.lab=c("TB+","TB-","TB+","TB-"),
       ilab.xpos=c(-9.5,-8,-6,-4.5), cex=0.75, header="Author(s) and Year",
       mlab="", shade=TRUE)
text(c(-8.75,-5.25), res$k+3, c("Vaccinated", "Control"), cex=0.75, font=2)

Solution

  • The decimal symbol can be controlled (globally within R) via options() -- see help(options) and in particular OutDec. So just use options(OutDec="-") before creating the plot. I am not going to comment on the fact that using a dash as a decimal symbol is weird (and confusing) as hell.