mtc.network 错误 "Error in `levels<-`(`*tmp*`, value = as.character(levels)) : factor level [5] is duplicated"
mtc.network error "Error in `levels<-`(`*tmp*`, value = as.character(levels)) : factor level [5] is duplicated"
我在这里看到了一些与我的查询类似的问题,但这些解决方案对我没有用。我正在尝试构建网络元分析,但在调用 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
如有任何帮助,我将不胜感激。
似乎该函数需要以特定方式格式化数据。我们可以像示例数据集中那样更改列名,它会起作用
names(df) <- c("study", "sampleSize", "responders", "treatment")
network <- mtc.network(df, description="Example", treatments=unique(df$treatment))
我在这里看到了一些与我的查询类似的问题,但这些解决方案对我没有用。我正在尝试构建网络元分析,但在调用 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
如有任何帮助,我将不胜感激。
似乎该函数需要以特定方式格式化数据。我们可以像示例数据集中那样更改列名,它会起作用
names(df) <- c("study", "sampleSize", "responders", "treatment")
network <- mtc.network(df, description="Example", treatments=unique(df$treatment))