[R-meta] Add a reference/citation number to author name in forest plot
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
-----Original Message----- From: Dylan Johnson [mailto:dylanr.johnson at mail.utoronto.ca] Sent: Monday, 08 February, 2021 23:02 To: r-sig-meta-analysis at r-project.org Cc: Viechtbauer, Wolfgang (SP) Subject: Add a reference/citation number to author name in forest plot 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