Running examples in ‘metafor-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: dat.senn2013
> ### Title: Studies on the Effectiveness of Glucose-Lowering Agents
> ### Aliases: dat.senn2013
> ### Keywords: datasets
> 
> ### ** Examples
> 
> ### copy data into 'dat' and examine data
> dat <- dat.senn2013
> dat
                   study  ni     treatment comment    mi   sdi
1       De Fronzo (1995) 213     metformin  change -1.70 1.459
2       De Fronzo (1995) 209       placebo  change  0.20 1.446
3           Lewin (2007) 431     metformin  change -0.74 1.106
4           Lewin (2007) 144       placebo  change  0.08 1.004
5          Willms (1999)  29     metformin  change -2.50 0.862
6          Willms (1999)  31      acarbose  change -2.30 1.782
7          Willms (1999)  29       placebo  change -1.30 1.831
8        Davidson (2007) 117 rosiglitazone  change -1.20 1.097
9        Davidson (2007) 116       placebo  change  0.14 1.093
10  Wolffenbuttel (1999) 183 rosiglitazone  change -0.90 1.100
11  Wolffenbuttel (1999) 192       placebo  change  0.20 1.110
12         Kipnes (2001) 182  pioglitazone  change -1.20 1.369
13         Kipnes (2001) 181       placebo  change  0.10 1.024
14        Kerenyi (2004) 160 rosiglitazone  change -0.91 0.990
15        Kerenyi (2004) 154       placebo  change -0.14 0.920
16       Hanefeld (2004) 319  pioglitazone     raw  7.61 1.072
17       Hanefeld (2004) 320     metformin     raw  7.45 1.073
18         Derosa (2004)  45  pioglitazone     raw  6.80 0.800
19         Derosa (2004)  42 rosiglitazone     raw  6.70 0.900
20          Baksi (2004) 218 rosiglitazone  change -1.20 1.112
21          Baksi (2004) 233       placebo  change  0.10 1.036
22     Rosenstock (2008)  59 rosiglitazone  change -1.17 1.229
23     Rosenstock (2008)  57       placebo  change -0.08 1.208
24            Zhu (2003) 210 rosiglitazone  change -1.90 1.470
25            Zhu (2003) 105       placebo  change -0.40 1.300
26           Yang (2003) 102 rosiglitazone  change -1.09 1.650
27           Yang (2003)  96     metformin  change -0.95 1.500
28 Vongthavaravat (2002) 164 rosiglitazone  change -1.10 1.559
29 Vongthavaravat (2002) 170  sulfonylurea  change  0.10 0.992
30          Oyama (2008)  41      acarbose  change -0.70 0.800
31          Oyama (2008)  43  sulfonylurea  change -0.30 0.600
32          Costa (1997)  36      acarbose  change -1.10 0.360
33          Costa (1997)  29       placebo  change -0.30 0.700
34      Hermansen (2007) 106   sitagliptin  change -0.30 0.940
35      Hermansen (2007) 106       placebo  change  0.27 0.940
36         Garber (2008) 132  vildagliptin  change -0.63 1.034
37         Garber (2008) 144       placebo  change  0.07 1.080
38           Alex (1998) 291     metformin  change  0.13 1.428
39           Alex (1998) 300  sulfonylurea  change  0.50 1.450
40       Johnston (1994)  68      miglitol  change -0.41 1.072
41       Johnston (1994)  63       placebo  change  0.33 1.032
42      Johnston (1998a)  91      miglitol  change -0.43 0.954
43      Johnston (1998a)  43       placebo  change  0.98 1.311
44            Kim (2007)  57 rosiglitazone  change -1.10 1.341
45            Kim (2007)  56     metformin  change -1.10 1.139
46      Johnston (1998b)  49      miglitol  change -0.12 1.400
47      Johnston (1998b)  34       placebo  change  0.56 1.166
48 Gonzalez-Ortiz (2004)  34     metformin  change -1.30 1.861
49 Gonzalez-Ortiz (2004)  37       placebo  change -0.90 1.803
50         Stucci (1996)  28    benfluorex     raw  8.03 1.290
51         Stucci (1996)  30       placebo     raw  8.26 1.350
52         Moulin (2006) 161    benfluorex  change -0.82 1.028
53         Moulin (2006) 156       placebo  change  0.19 1.374
> 
> ### create network graph ('plyr' and 'igraph' packages must be installed)
> ## Not run: 
> ##D require(plyr)
> ##D require(igraph)
> ##D pairs <- do.call(rbind, sapply(split(dat$treatment, dat$study), function(x) t(combn(x,2))))
> ##D pairs <- ddply(data.frame(pairs), .(X1, X2), count)
> ##D g <- graph.edgelist(as.matrix(pairs[,1:2]), directed=FALSE)
> ##D plot(g, edge.curved=FALSE, edge.width=pairs$freq, vertex.label.dist=.8)
> ## End(Not run)
> 
> ### table of studies versus treatments examined
> print(addmargins(table(dat$study, dat$treatment)), zero.print="")
                       
                        acarbose benfluorex metformin miglitol pioglitazone
  Alex (1998)                                       1                      
  Baksi (2004)                                                             
  Costa (1997)                 1                                           
  Davidson (2007)                                                          
  De Fronzo (1995)                                  1                      
  Derosa (2004)                                                           1
  Garber (2008)                                                            
  Gonzalez-Ortiz (2004)                             1                      
  Hanefeld (2004)                                   1                     1
  Hermansen (2007)                                                         
  Johnston (1994)                                            1             
  Johnston (1998a)                                           1             
  Johnston (1998b)                                           1             
  Kerenyi (2004)                                                           
  Kim (2007)                                        1                      
  Kipnes (2001)                                                           1
  Lewin (2007)                                      1                      
  Moulin (2006)                           1                                
  Oyama (2008)                 1                                           
  Rosenstock (2008)                                                        
  Stucci (1996)                           1                                
  Vongthavaravat (2002)                                                    
  Willms (1999)                1                    1                      
  Wolffenbuttel (1999)                                                     
  Yang (2003)                                       1                      
  Zhu (2003)                                                               
  Sum                          3          2         8        3            3
                       
                        placebo rosiglitazone sitagliptin sulfonylurea
  Alex (1998)                                                        1
  Baksi (2004)                1             1                         
  Costa (1997)                1                                       
  Davidson (2007)             1             1                         
  De Fronzo (1995)            1                                       
  Derosa (2004)                             1                         
  Garber (2008)               1                                       
  Gonzalez-Ortiz (2004)       1                                       
  Hanefeld (2004)                                                     
  Hermansen (2007)            1                         1             
  Johnston (1994)             1                                       
  Johnston (1998a)            1                                       
  Johnston (1998b)            1                                       
  Kerenyi (2004)              1             1                         
  Kim (2007)                                1                         
  Kipnes (2001)               1                                       
  Lewin (2007)                1                                       
  Moulin (2006)               1                                       
  Oyama (2008)                                                       1
  Rosenstock (2008)           1             1                         
  Stucci (1996)               1                                       
  Vongthavaravat (2002)                     1                        1
  Willms (1999)               1                                       
  Wolffenbuttel (1999)        1             1                         
  Yang (2003)                               1                         
  Zhu (2003)                  1             1                         
  Sum                        19            10           1            3
                       
                        vildagliptin Sum
  Alex (1998)                          2
  Baksi (2004)                         2
  Costa (1997)                         2
  Davidson (2007)                      2
  De Fronzo (1995)                     2
  Derosa (2004)                        2
  Garber (2008)                    1   2
  Gonzalez-Ortiz (2004)                2
  Hanefeld (2004)                      2
  Hermansen (2007)                     2
  Johnston (1994)                      2
  Johnston (1998a)                     2
  Johnston (1998b)                     2
  Kerenyi (2004)                       2
  Kim (2007)                           2
  Kipnes (2001)                        2
  Lewin (2007)                         2
  Moulin (2006)                        2
  Oyama (2008)                         2
  Rosenstock (2008)                    2
  Stucci (1996)                        2
  Vongthavaravat (2002)                2
  Willms (1999)                        3
  Wolffenbuttel (1999)                 2
  Yang (2003)                          2
  Zhu (2003)                           2
  Sum                              1  53
> 
> ### table of frequencies with which treatment pairs were studied
> print(as.table(crossprod(table(dat$study, dat$treatment))), zero.print="")
               
                acarbose benfluorex metformin miglitol pioglitazone placebo
  acarbose             3                    1                             2
  benfluorex                      2                                       2
  metformin            1                    8                     1       4
  miglitol                                           3                    3
  pioglitazone                              1                     3       1
  placebo              2          2         4        3            1      19
  rosiglitazone                             2                     1       6
  sitagliptin                                                             1
  sulfonylurea         1                    1                              
  vildagliptin                                                            1
               
                rosiglitazone sitagliptin sulfonylurea vildagliptin
  acarbose                                           1             
  benfluorex                                                       
  metformin                 2                        1             
  miglitol                                                         
  pioglitazone              1                                      
  placebo                   6           1                         1
  rosiglitazone            10                        1             
  sitagliptin                           1                          
  sulfonylurea              1                        3             
  vildagliptin                                                    1
> 
> ### add means and sampling variances of the means to the dataset
> dat <- escalc(measure="MN", mi=mi, sdi=sdi, ni=ni, data=dat)
> 
> ### turn treatment variable into factor and set reference level
> dat$treatment <- relevel(factor(dat$treatment), ref="placebo")
> 
> ### add a space before each level (this makes the output a bit more legible)
> levels(dat$treatment) <- paste0(" ", levels(dat$treatment))
> 
> ### network meta-analysis using an arm-based fixed-effects model with fixed study effects
> res.fe <- rma.mv(yi, vi, mods = ~ study + treatment - 1, data=dat, slab=paste0(study, treatment))
> res.fe

Multivariate Meta-Analysis Model (k = 53; method: REML)

Variance Components: none

Test for Residual Heterogeneity:
QE(df = 18) = 96.9841, p-val < .0001

Test of Moderators (coefficients 1:35):
QM(df = 35) = 42156.8401, p-val < .0001

Model Results:

                            estimate      se      zval    pval    ci.lb 
studyAlex (1998)              1.0917  0.0866   12.6029  <.0001   0.9219 
studyBaksi (2004)             0.0560  0.0548    1.0230  0.3063  -0.0513 
studyCosta (1997)            -0.2775  0.1047   -2.6496  0.0081  -0.4827 
studyDavidson (2007)          0.0709  0.0756    0.9377  0.3484  -0.0773 
studyDe Fronzo (1995)        -0.1932  0.0767   -2.5176  0.0118  -0.3436 
studyDerosa (2004)            7.8814  0.1041   75.7432  <.0001   7.6774 
studyGarber (2008)            0.0700  0.0900    0.7778  0.4367  -0.1064 
studyGonzalez-Ortiz (2004)   -0.5693  0.2189   -2.6004  0.0093  -0.9984 
studyHanefeld (2004)          8.6201  0.0724  119.1426  <.0001   8.4783 
studyHermansen (2007)         0.2700  0.0913    2.9573  0.0031   0.0911 
studyJohnston (1994)          0.4319  0.1117    3.8667  0.0001   0.2130 
studyJohnston (1998a)         0.6071  0.1353    4.4877  <.0001   0.3420 
studyJohnston (1998b)         0.6919  0.1550    4.4642  <.0001   0.3881 
studyKerenyi (2004)           0.0642  0.0584    1.1008  0.2710  -0.0501 
studyKim (2007)               0.0512  0.1235    0.4147  0.6783  -0.1908 
studyKipnes (2001)            0.0158  0.0667    0.2375  0.8123  -0.1149 
studyLewin (2007)             0.2892  0.0618    4.6804  <.0001   0.1681 
studyMoulin (2006)            0.1220  0.1051    1.1609  0.2457  -0.0840 
studyOyama (2008)             0.1352  0.1100    1.2290  0.2191  -0.0804 
studyRosenstock (2008)       -0.0241  0.1156   -0.2082  0.8351  -0.2507 
studyStucci (1996)            8.6013  0.1849   46.5307  <.0001   8.2390 
studyVongthavaravat (2002)    0.4165  0.0954    4.3644  <.0001   0.2295 
studyWillms (1999)           -1.3878  0.1402   -9.9014  <.0001  -1.6625 
studyWolffenbuttel (1999)     0.2502  0.0617    4.0542  <.0001   0.1292 
studyYang (2003)              0.1396  0.1196    1.1680  0.2428  -0.0947 
studyZhu (2003)              -0.5819  0.0844   -6.8947  <.0001  -0.7473 
treatment acarbose           -0.8273  0.1085   -7.6252  <.0001  -1.0400 
treatment benfluorex         -0.9051  0.1271   -7.1211  <.0001  -1.1543 
treatment metformin          -1.1140  0.0596  -18.6892  <.0001  -1.2309 
treatment miglitol           -0.9438  0.1269   -7.4375  <.0001  -1.1926 
treatment pioglitazone       -1.0663  0.0758  -14.0590  <.0001  -1.2149 
treatment rosiglitazone      -1.2019  0.0477  -25.2158  <.0001  -1.2953 
treatment sitagliptin        -0.5700  0.1291   -4.4145  <.0001  -0.8231 
treatment sulfonylurea       -0.4394  0.0915   -4.8041  <.0001  -0.6187 
treatment vildagliptin       -0.7000  0.1273   -5.4998  <.0001  -0.9495 
                              ci.ub 
studyAlex (1998)             1.2615  *** 
studyBaksi (2004)            0.1633      
studyCosta (1997)           -0.0722   ** 
studyDavidson (2007)         0.2191      
studyDe Fronzo (1995)       -0.0428    * 
studyDerosa (2004)           8.0853  *** 
studyGarber (2008)           0.2464      
studyGonzalez-Ortiz (2004)  -0.1402   ** 
studyHanefeld (2004)         8.7619  *** 
studyHermansen (2007)        0.4489   ** 
studyJohnston (1994)         0.6509  *** 
studyJohnston (1998a)        0.8723  *** 
studyJohnston (1998b)        0.9957  *** 
studyKerenyi (2004)          0.1786      
studyKim (2007)              0.2933      
studyKipnes (2001)           0.1466      
studyLewin (2007)            0.4103  *** 
studyMoulin (2006)           0.3280      
studyOyama (2008)            0.3508      
studyRosenstock (2008)       0.2025      
studyStucci (1996)           8.9636  *** 
studyVongthavaravat (2002)   0.6035  *** 
studyWillms (1999)          -1.1131  *** 
studyWolffenbuttel (1999)    0.3711  *** 
studyYang (2003)             0.3740      
studyZhu (2003)             -0.4165  *** 
treatment acarbose          -0.6147  *** 
treatment benfluorex        -0.6560  *** 
treatment metformin         -0.9972  *** 
treatment miglitol          -0.6951  *** 
treatment pioglitazone      -0.9176  *** 
treatment rosiglitazone     -1.1084  *** 
treatment sitagliptin       -0.3169  *** 
treatment sulfonylurea      -0.2601  *** 
treatment vildagliptin      -0.4505  *** 

---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

> 
> ### test if treatment factor as a whole is significant
> anova(res.fe, btt="treatment")

Test of Moderators (coefficients 27:35):
QM(df = 9) = 1060.3371, p-val < .0001

> 
> ### forest plot of the contrast estimates (treatments versus placebos)
> dev.new(width=7, height=5)
dev.new(): using pdf(file="Rplots1.pdf")
> forest(tail(coef(res.fe), 9), tail(diag(vcov(res.fe)), 9), slab=levels(dat$treatment)[-1],
+        xlim=c(-2.5, 2.0), alim=c(-1.5, 0.5), psize=1, xlab="Estimate", header="Treatment")
> 
> ### weight matrix for the estimation of the fixed effects (leaving out study effects)
> w <- t(tail(vcov(res.fe) %*% t(model.matrix(res.fe)) %*% weights(res.fe, type="matrix"), 9))
> rownames(w) <- res.fe$slab
> 
> ### create shade plot for the diabetes network with placebo as the reference treatment
> ### negative values in blue shades, positive values in red shades
> dev.new()
dev.new(): using pdf(file="Rplots2.pdf")
> cols <- colorRampPalette(c("blue", "gray95", "red"))(9)
> heatmap(w, Rowv=NA, Colv=NA, scale="none", margins=c(6,11), col=cols,
+         cexRow=.7, cexCol=1, labCol=levels(dat$treatment)[-1])
Error in axis(1, 1L:nc, labels = labCol, las = 2, line = -0.5, tick = 0,  : 
  'at' and 'labels' lengths differ, 9 != 53
Calls: heatmap -> axis
Execution halted