Skip to content

[R-meta] Add a reference/citation number to author name in forest plot

3 messages · Wolfgang Viechtbauer, Dylan Johnson

#
Hello,

The journal that I am submitting to has requested that I add AMA format reference numbers for each article in the forest plot, in the format:

Johnson et al.,1 2020

Does anyone have advice for how I can go about this with the forest.rma function?

Thanks!

Dylan


Dylan Johnson, MSc

MA Student, School and Clinical Child Psychology
Department of Applied Psychology and Human Development

University of Toronto
252 Bloor Street West

Toronto, ON M5S 1V6
#
Hi Dylan,

Depends to what extent you want to do this 'manually'. Here is an example:

library(metafor)
dat <- dat.bcg

labs <- paste(dat$author, dat$year)
labs[1] <- expression(paste("Aronson,", plain()^1, " 1948"))

res <- rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat, measure="RR", method="REML")
forest(res, slab = labs)

So here I am 'hardcoding' the author, reference number, and year number for the first study and the same could be done for the others. If you don't have a lot of studies, then this could be done by hand.

If you want to do this 'programmatically', it gets a bit more tricky, because you have to substitute values, plus generate an expression that can be used for 'math plotting'. A bit of a nightmarish solution would be:

labs <- mapply(function(x,y,z) as.expression(bquote(.(x)^.(y)*","~.(z))), dat$author, dat$trial, dat$year)
forest(res, slab = labs)

Best,
Wolfgang
#
Thanks Wolfgang, I will give the latter a try as I have many effects per forest plot.



Best,

Dylan



Dylan Johnson, MSc



MA Student, School and Clinical Child Psychology
Department of Applied Psychology and Human Development

University of Toronto
252 Bloor Street West

Toronto, ON M5S 1V6



From: Viechtbauer, Wolfgang (SP)<mailto:wolfgang.viechtbauer at maastrichtuniversity.nl>
Sent: February 8, 2021 5:36 PM
To: Dylan Johnson<mailto:dylanr.johnson at mail.utoronto.ca>; r-sig-meta-analysis at r-project.org<mailto:r-sig-meta-analysis at r-project.org>
Subject: RE: Add a reference/citation number to author name in forest plot



EXTERNAL EMAIL:

Hi Dylan,

Depends to what extent you want to do this 'manually'. Here is an example:

library(metafor)
dat <- dat.bcg

labs <- paste(dat$author, dat$year)
labs[1] <- expression(paste("Aronson,", plain()^1, " 1948"))

res <- rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat, measure="RR", method="REML")
forest(res, slab = labs)

So here I am 'hardcoding' the author, reference number, and year number for the first study and the same could be done for the others. If you don't have a lot of studies, then this could be done by hand.

If you want to do this 'programmatically', it gets a bit more tricky, because you have to substitute values, plus generate an expression that can be used for 'math plotting'. A bit of a nightmarish solution would be:

labs <- mapply(function(x,y,z) as.expression(bquote(.(x)^.(y)*","~.(z))), dat$author, dat$trial, dat$year)
forest(res, slab = labs)

Best,
Wolfgang