使用 CreateTableOne 时出现“列的重复下标”错误

问题描述 投票:0回答:1

我尝试使用以下代码从

CreateTableOne
数据集的 m.dataaaaaa 包中执行
tableone

CreateTableOne(vars =Vars,strata = "ejecfraclesstha40_gps",  factorVars =Catvars, data = m.dataaaaaa,  test = T)

但是我收到以下错误:

[<-.data.frame
(x, i, value = value) 中的错误:重复 列的下标 另外:警告消息:在 ModuleReturnVarsExist(vars, data) :数据框没有: ejecfraclesstha40 已掉落

数据结构如下所示,因为它是一个大数据库

str(m.dataaaaaa)

Classes ‘data.table’ and 'data.frame':  194 obs. of  203 variables:
 $ ejecfraclesstha40_gps                       : num  1 0 1 0 0 0 1 1 1 0 ...
 $ Serial.ID                                   : num  2 3 4 7 10 14 17 20 23 24 ...
  ..- attr(*, "format.spss")= chr "F4.0"
 $ Serial.ID_matched.EF.cohort.Ivan1.to.2      : num  2 NA 4 NA NA NA 17 20 23 NA ...
  ..- attr(*, "format.spss")= chr "F8.0"
 $ ps..matched.EF.cohort.Ivan1.to.2            : num  0.138 NA 0.19 NA NA NA 0.176 0.286 0.152 NA ...
  ..- attr(*, "format.spss")= chr "F8.3"
 $ psweight1.to.2                              : num  1 NA 1 NA NA NA 1 1 1 NA ...
  ..- attr(*, "format.spss")= chr "F8.2"
 $ matched_ID1.to.2                            : num  483 NA 763 NA NA NA 180 176 239 NA ...
  ..- attr(*, "format.spss")= chr "F8.2"
 $ matched_cases_in_control1.to.2              : num  2 NA 2 NA NA NA 2 2 2 NA ...
  ..- attr(*, "format.spss")= chr "F8.2"
 $ ejecfrac_4gps                               : num  1 3 1 3 3 3 1 1 1 3 ...
  ..- attr(*, "format.spss")= chr "F8.2"
  ..- attr(*, "labels")= Named num  1 2 3 4
  .. ..- attr(*, "names")= chr  "EF<35%" "EF=35 - <40%" "EF=40 - <=50" "EF>50%"
 $ ejecfrac_4gps30                             : num  1 4 1 3 3 4 1 1 1 4 ...
  ..- attr(*, "format.spss")= chr "F8.2"
  ..- attr(*, "labels")= Named num  1 2 3 4
  .. ..- attr(*, "names")= chr  "EF<=30%" "EF>30 - 39%" "EF=40 - 49%" "EF>=50%"
 $ renisch                                     : num  29 31 23 18 48 19 10 29 17 13 ...
  ..- attr(*, "label")= chr "renal + visceral ischemic time"
  ..- attr(*, "format.spss")= chr "F3.0"
  ..- attr(*, "display_width")= int 12
 $ totxct                                      : num  46 31 55 46 48 19 54 29 17 37 ...
  ..- attr(*, "label")= chr "total cross-clamp time"
  ..- attr(*, "format.spss")= chr "F4.0"
  ..- attr(*, "display_width")= int 12

原始数据库从spss读入r。 我的主要问题是这个错误:

[错误<-.data.frame(x, i, value = value) : duplicate subscripts for columns

任何建议将不胜感激。

r create-table
1个回答
0
投票

我通过将

factorVars
参数下列出的分类变量从数字转换为因子来解决这个问题。
    

© www.soinside.com 2019 - 2024. All rights reserved.