[R-meta] How to replace labels in metafor forest plots?

Lukasz Stasielowicz |uk@@z@@t@@|e|ow|cz @end|ng |rom un|-o@n@brueck@de
Thu Jul 31 16:19:59 CEST 2025


Dear Iago,

You could switch off the header() argument for the estimates and supply 
the desired labels via text(). Based on your example code:



dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg,
               slab=paste(author, year, sep=", "), data=dat.bcg)
res <- rma(yi, vi, data=dat)
forest(res, addpred=TRUE, xlim=c(-16,7), at=seq(-3,2,by=1), shade=TRUE,
        ilab=cbind(tpos, tneg, cpos, cneg), ilab.xpos=c(-9.5, -8, -6,
                                                        -4.5),
        ilab.lab=c("TB+", "TB-", "TB+", "TB-"), cex=0.75,
        header=c("Author(s) and Year",""))
text(c(-8.75, -5.25), res$k+2.8, c("Vaccinated", "Control"), cex=0.75,
      font=2)
text(6,nrow(dat)+2,"Hazard Ratio",cex=0.75,font=2)




Best,
Lukasz
-- 
Lukasz Stasielowicz
https://stasielowicz.com/

On 31/07/2025 12:00, r-sig-meta-analysis-request using r-project.org wrote:
> Send R-sig-meta-analysis mailing list submissions to
> 	r-sig-meta-analysis using r-project.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> 	https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis
> or, via email, send a message with subject or body 'help' to
> 	r-sig-meta-analysis-request using r-project.org
> 
> You can reach the person managing the list at
> 	r-sig-meta-analysis-owner using r-project.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of R-sig-meta-analysis digest..."
> 
> 
> Today's Topics:
> 
>     1. How to replace labels in metafor forest plots? (iagogv)
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Wed, 30 Jul 2025 13:05:45 +0200
> From: iagogv <iagogv using disroot.org>
> To: R-sig-meta Analysis <r-sig-meta-analysis using r-project.org>
> Subject: [R-meta] How to replace labels in metafor forest plots?
> Message-ID: <dad104c5f606cce852c2143bca16be9c using disroot.org>
> Content-Type: text/plain; charset="utf-8"
> 
> Hi all,
> 
> Let's say we have the common example
> 
> dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg,
>                 slab=paste(author, year, sep=", "), data=dat.bcg)
> res <- rma(yi, vi, data=dat)
> forest(res, addpred=TRUE, xlim=c(-16,7), at=seq(-3,2,by=1), shade=TRUE,
>          ilab=cbind(tpos, tneg, cpos, cneg), ilab.xpos=c(-9.5, -8, -6,
> -4.5),
>          ilab.lab=c("TB+", "TB-", "TB+", "TB-"), cex=0.75,
> header="Author(s) and Year")
> text(c(-8.75, -5.25), res$k+2.8, c("Vaccinated", "Control"), cex=0.75,
> font=2)
> 
> The header of the estimates column is Log [RR] [95% CI].
> 
> I would like to change it (actually, my estimates are Hazard Ratios, and
> I want to replace the label 'Estimate' by 'Hazard Ratio'), but adding
> text in the same position just add the new text, but does not remove the
> original label. How can I replace this label?
> 
> Thank you for your help!
> 
> Iago
> 	[[alternative HTML version deleted]]
> 
> 
> 
> 
> ------------------------------
> 
> Subject: Digest Footer
> 
> _______________________________________________
> R-sig-meta-analysis mailing list @ R-sig-meta-analysis using r-project.org
> To manage your subscription to this mailing list, go to:
> https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis
> 
> 
> ------------------------------
> 
> End of R-sig-meta-analysis Digest, Vol 98, Issue 2
> **************************************************


-- 
Diese E-Mail wurde von Avast-Antivirussoftware auf Viren geprüft.
www.avast.com



More information about the R-sig-meta-analysis mailing list