1

我在这里看到了一些与我的查询类似的问题,但这些解决方案对我不起作用。我正在尝试构建网络元分析,并在调用mtc.network命令后遇到以下错误:

Error in `levels<-`(`*tmp*`, value = as.character(levels)) : factor level [5] is duplicated

我的数据是

library(gemtc)
library(rjags)

study<-c("Jones", "Jones", "Prieto", "Prieto", "Scott", "Scott", "Mickle", "Mickle", "Yang", "Yang", "Zhao", "Zhao")
n<-c(3886, 3876, 218, 214, 2040, 2014, 137, 137, 683, 683, 221, 230)
surv<-c(114, 94, 3, 8, 30, 20, 1, 4, 9, 11, 1, 2)
treat<-c("dx1", "px1", "rx1", "tx1", "rx1", "ax1", "zx1", "tx1", "gx1", "tx1", "ax1", "px1")

df<-data.frame(study, n, surv, treat)

network1<-mtc.network(data.ab=df, treatments=df$treat)

然后我收到此消息

Error in `levels<-`(`*tmp*`, value = as.character(levels)) : 
  factor level [5] is duplicated

我将不胜感激在这方面的任何帮助。

4

1 回答 1

0

该函数似乎需要以特定方式格式化数据。我们可以像示例数据集中一样更改列名,它会起作用

names(df) <- c("study", "sampleSize", "responders", "treatment")
network <- mtc.network(df, description="Example", treatments=unique(df$treatment)) 
于 2020-12-23T23:33:23.523 回答