guido-s / meta

Official Git repository of R package meta
http://cran.r-project.org/web/packages/meta/index.html
GNU General Public License v2.0
82 stars 32 forks source link

Subgroup plot with metaprop "Error in x$labels[[i]] : subscript out of bounds" #48

Closed fohofmann closed 1 year ago

fohofmann commented 1 year ago

Hi everyone.

I am trying to calculate proportional meta.analysis with clusters and subgroups. The meta-analysis works fine and as expected, however, forest() seems - at least for me - broken:

forest(res, subgroup=T) Error in x$labels[[i]] : subscript out of bounds

A reproducible example:

# libraries
library(meta)
library(data.table)

# data
dt = data.table(
 ID = rep(1:5, each=3),
 AE = rep(c("minor","major","deadly"),5),
 ni = rep(c(25,19,101,32,50), each=3),
 xi = c(2,3,3,4,1,0,29,13,4,7,4,1,7,2,1) )

# meta-analysis & forest plot
res = metaprop(xi, ni, cluster=ID, subgroup=AE, data=dt, tau.common=T)
forest(res)

A similar issue was described earlier for metamean() ( #41 ), but was solved meanwhile.

Any help would be highly appreciated. Best, Felix

guido-s commented 1 year ago

Thank you for pointing out this bug (not directly related to issue #41). Should be fixed now.