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

print() method in subgroup analysis in metacont() with factors #14

Closed fmmattioni closed 5 years ago

fmmattioni commented 5 years ago

If I have a grouping column that is a factor() the print method prints the group levels instead of the group labels (see the group column at the very beginning of the output below). Is there an option to change it?

reprex:

library(meta)
#> Loading 'meta' package (version 4.9-7).
#> Type 'help(meta)' for a brief overview.

data(Fleiss93cont)

# Generate additional variable with grouping information

Fleiss93cont$group <- factor(c(1, 2, 1, 1, 2), labels = c("Treatment A", "Treatment B"))

m2 <- metacont(n.e, mean.e, sd.e, n.c, mean.c, sd.c, study,
               data = Fleiss93cont, sm = "SMD", byvar = group)

print(m2)
#>             SMD             95%-CI %W(fixed) %W(random) group
#> Davis   -0.3399 [-1.1152;  0.4354]      11.5       11.5     1
#> Florell -0.5659 [-1.0274; -0.1044]      32.6       32.6     2
#> Gruen   -0.2999 [-0.7712;  0.1714]      31.2       31.2     1
#> Hart     0.1250 [-0.4954;  0.7455]      18.0       18.0     1
#> Wilson  -0.7346 [-1.7575;  0.2883]       6.6        6.6     2
#> 
#> Number of studies combined: k = 5
#> 
#>                          SMD             95%-CI     z p-value
#> Fixed effect model   -0.3434 [-0.6068; -0.0800] -2.56  0.0106
#> Random effects model -0.3434 [-0.6068; -0.0800] -2.56  0.0106
#> 
#> Quantifying heterogeneity:
#> tau^2 = 0; H = 1.00 [1.00; 2.10]; I^2 = 0.0% [0.0%; 77.4%]
#> 
#> Quantifying residual heterogeneity:
#> H = 1.00 [1.00; 1.76]; I^2 = 0.0% [0.0%; 67.8%]
#> 
#> Test of heterogeneity:
#>     Q d.f. p-value
#>  3.68    4  0.4515
#> 
#> Results for subgroups (fixed effect model):
#>                       k     SMD             95%-CI    Q tau^2  I^2
#> group = Treatment A   3 -0.1815 [-0.5194;  0.1563] 1.34     0 0.0%
#> group = Treatment B   2 -0.5944 [-1.0151; -0.1738] 0.09     0 0.0%
#> 
#> Test for subgroup differences (fixed effect model):
#>                   Q d.f. p-value
#> Between groups 2.25    1  0.1336
#> Within groups  1.43    3  0.6992
#> 
#> Results for subgroups (random effects model):
#>                       k     SMD             95%-CI    Q tau^2  I^2
#> group = Treatment A   3 -0.1815 [-0.5194;  0.1563] 1.34     0 0.0%
#> group = Treatment B   2 -0.5944 [-1.0151; -0.1738] 0.09     0 0.0%
#> 
#> Test for subgroup differences (random effects model):
#>                     Q d.f. p-value
#> Between groups   2.25    1  0.1336
#> 
#> Details on meta-analytical method:
#> - Inverse variance method
#> - DerSimonian-Laird estimator for tau^2
#> - Hedges' g (bias corrected standardised mean difference)

Created on 2019-10-01 by the reprex package (v0.3.0)

guido-s commented 5 years ago

Thank you for reporting this issue. I just solved this in https://github.com/guido-s/meta/commit/c6a9bf6cf873cba1c77983f0d036cfdc99a6c046 by using as.character(x$byvar) instead of x$byvar to generate the matrix with study information in print.meta().

guido-s commented 5 years ago

Issue solved.