The metafor Package

A Meta-Analysis Package for R

User Tools

Site Tools


plots:forest_plot_with_subgroups

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
plots:forest_plot_with_subgroups [2022/04/22 11:17] Wolfgang Viechtbauerplots:forest_plot_with_subgroups [2023/09/21 19:09] (current) Wolfgang Viechtbauer
Line 26: Line 26:
  
 ### a little helper function to add Q-test, I^2, and tau^2 estimate info ### a little helper function to add Q-test, I^2, and tau^2 estimate info
-mlabfun <- function(text, res) {+mlabfun <- function(text, x) {
    list(bquote(paste(.(text),    list(bquote(paste(.(text),
-      " (Q = ", .(formatC(res$QE, digits=2, format="f")), +      " (Q = ", .(fmtx(x$QE, digits=2)), 
-      ", df = ", .(res$k - res$p), +      ", df = ", .(x$k - x$p), ", ", 
-      ", ", .(metafor:::.pval(res$QEp, digits=2showeq=TRUE, sep=" ")), "; ", +      .(fmtp(x$QEp, digits=3pname="p", add0=TRUE, sep=TRUE, equal=TRUE)), "; ", 
-      I^2, " = ", .(formatC(res$I2, digits=1, format="f")), "%, ", +      I^2, " = ", .(fmtx(x$I2, digits=1)), "%, ", 
-      tau^2, " = ", .(formatC(res$tau2, digits=2, format="f")), ")")))}+      tau^2, " = ", .(fmtx(x$tau2, digits=2)), ")")))}
  
 ### set up forest plot (with 2x2 table counts added; the 'rows' argument is ### set up forest plot (with 2x2 table counts added; the 'rows' argument is
Line 75: Line 75:
 ### add text for the test of subgroup differences ### add text for the test of subgroup differences
 text(-16, -1.8, pos=4, cex=0.75, bquote(paste("Test for Subgroup Differences: ", text(-16, -1.8, pos=4, cex=0.75, bquote(paste("Test for Subgroup Differences: ",
-     Q[M], " = ", .(formatC(res$QM, digits=2, format="f")), ", df = ", .(res$p - 1), +     Q[M], " = ", .(fmtx(res$QM, digits=2)), 
-     ", p = ", .(formatC(res$QMp, digits=2, format="f")))))+     ", df = ", .(res$p - 1), ", ", 
 +     .(fmtp(res$QMp, digits=2, pname="p", add0=TRUE, sep=TRUE, equal=TRUE)))))
 </code> </code>
  
plots/forest_plot_with_subgroups.txt · Last modified: 2023/09/21 19:09 by Wolfgang Viechtbauer