Search code examples
reditorr-forestplot

How do I edit the columns of a meta::forest plot without losing plot summary information? I'm following Harrer meta-analysis in R bookdown


First-time user, fairly new to R, sorry if this question is not brilliantly asked...

Problem:

My forest plot in R using meta went well until it comes to editing using the parameters described here https://bookdown.org/MathiasHarrer/Doing_Meta_Analysis_in_R/generating-a-forest-plot.html

Question:

Can anyone detect why, when I use the meta parameter leftcols to change the columns to "Study, Cohort and Size" (from Study, TE and seTE), it labels the left columns as hoped for, BUT gets rid of “Random effect model total, Prediction interval and heterogeneity” text from the bottom left of the plot? It also centres the text in the left columns but I would ideally like it to remain left-aligned. Better even than just detecting why, can anyone suggest a work-around?

What I've tried:

I’ve tried using other parameters of meta::forest() to add back in info such as pooled.totals, print.I2, text.predict etc but once leftcols parameter is used it seems to override them. I can use leftlabs instead of leftcols to rename the columns but that leaves the values of these columns as before (Study, TE and seTE).

Code:

library(meta)
m.random.REML <- metagen(logTE,
                         logSE,
                         data=madata,
                         studlab=paste(Author),
                         comb.fixed = FALSE,
                         comb.random = TRUE,
                         method.tau= "REML",
                         hakn = FALSE,
                         prediction=TRUE, 
                         sm = "RR")

meta::forest(m.random.REML,
             sortvar = seTE, 
             comb.random = TRUE,
             rightlabs = c("RR", "95% CI", "Weight"),
        ######This next line is what causes the problem 
             leftcols = c("Study", "Cohort", "Size"),  
             
)

Solution

  • Spent ages stuck on this myself but this is what I got:

    You need to specify "studlab" as that is what essentially prints the summary and using leftcols overwrites this. You have already put the information into "studlab" when you created the meta. You then need to call it in the plot and relabel it as you wish:

    library(meta)
    m.random.REML <- metagen(logTE,
                         logSE,
                         data=madata,
                         studlab=paste(Author),
                         comb.fixed = FALSE,
                         comb.random = TRUE,
                         method.tau= "REML",
                         hakn = FALSE,
                         prediction=TRUE, 
                         sm = "RR")
    
    meta::forest(m.random.REML,
             sortvar = seTE, 
             comb.random = TRUE,
             rightlabs = c("RR", "95% CI", "Weight"),
        ######This next line is what causes the problem 
             leftcols = c("studlab", "Cohort", "Size"),  
             leftlabs = c("Study", "Cohort", "Size"))