Search code examples
rmetafor

How can I split a long forest plot when meta-analyzing with the metafor package in R?


I am conducting meta-analysis using the metafor package. Since my dataset includes many studies, the forest plot gets really long and I can barely read.

Is there any way I can split the forest plot?

Thank you.


Solution

  • You can tweak the output and do plots of subsets, like this:

    library(metafor)
    
    set.seed(5132)
    k <- 50
    vi <- rchisq(k, df=1) * .03
    yi <- rnorm(k, rnorm(k, 0.5, 0.4), sqrt(vi))
    
    res <- rma(yi, vi)
    
    # plot of studies 1:50
    forest(res)
    
    res2 <- res
    res2$vi.f <- res2$vi.f[1:25]
    
    # plot of studies 1:25
    forest(res2, xlim = c(-3, 4))
    
    res3 <- res
    res3$vi.f <- res3$vi.f[26:50]
    res3$yi.f <- res3$yi.f[26:50]
    res3$slab <- res3$slab[26:50]
    
    # plot of studies 26:50
    forest(res3, xlim = c(-3, 4))