Skip to content

[R-meta] How to use superscript in the forest plot (package 'meta')?

2 messages · Antonello Preti, Guido Schwarzer

#
Dear all, I would like to use superscript in the forest plot (package
'meta'). Essentially, I would like to plot a graph as in Lancet, with
Author, (year), and the numeric reference attached to the (year) in
superscript.
I've tried various combinations of ^ with no result.

The best solution so far is with this:

dat1$Study<- lapply(dat1$Study, trimws) ### to eliminate blank space at the
end of the string of the Author, (year)

studlab=paste(dat1$Study,dat1$a)

However, this is not a good solution, since the numeric reference is not in
superscript.

Any solution?

Thank you in advance.
Antonello
#
Antonello,

R function JAMAlabels() in meta can be used for JAMA labels, i.e., 
Author (Year) superscript index. At the moment there is no corresponding 
function for Lancet labels.

The following R code - adapted from JAMAlabels() - generates and uses 
Lancet labels in the forest plot:

library(meta)
data(Fleiss1993bin)

refs <- 20 + 1:7

Fleiss1993bin$mylabs <- NA
##
for (i in seq_len(nrow(Fleiss1993bin)))
 ? Fleiss1993bin$mylabs[i] <-
 ??? with(Fleiss1993bin,
 ???????? as.expression(substitute(study~(year)^ref,
 ????????????????????????????????? list(study = study[i],
 ?????????????????????????????????????? year = year[i],
 ?????????????????????????????????????? ref = refs[i]))))

m <- metabin(d.asp, n.asp, d.plac, n.plac, data = Fleiss1993bin, sm = "OR")

forest(m, studlab = mylabs)

Best,

Guido