tableone::CreateTableOne 未显示 smd(标准化均值差)

no smd (standardized mean differences) shown by tableone::CreateTableOne

在 R 中,我尝试使用 tableone::CreateTableOne 来计算数据帧上的 smd(标准化均值差)。我使用了本教程 (https://cran.r-project.org/web/packages/tableone/vignettes/smd.html) - 代码运行并很好地生成了所需的输出 table,包括 smd.

但是,如果我使用自己的数据,例如下面的测试数据,我得到 table 但没有 smd。可能我犯了一些愚蠢的错误,但是在尝试了很多事情之后(只有数字,更小或更大的数据集,分类变量作为因子(如在 r 帮助中)或字符(如在教程中)......)我无法弄清楚为什么我不要得到 smd.

# package tableone for CreateTableOne
if (!require("tableone"))  install.packages("tableone");  library("tableone") 
# producible test data
set.seed(1234)
d <- data.frame(age = rnorm(n = 200, mean = 50, 9),
                hair = as.factor(sample(x = c("brown", "black", "blond"), 200, replace = T)),
                group = sample(x = c("sick", "healthy"), 200, replace = T))
str(d)
# calculate and print the table
tabUnmatched <- tableone::CreateTableOne(vars = c("age", "hair"), strata = "group", data = d, test = FALSE, smd = TRUE)
print(tabUnmatched)

结果如下 table,没有 smd(也没有错误消息):

                 Stratified by group
                  healthy       sick         
  n                  90           110        
  age (mean (SD)) 49.18 (7.97)  49.72 (10.10)
  hair (%)                                   
     black           30 (33.3)     35 (31.8) 
     blond           33 (36.7)     43 (39.1) 
     brown           27 (30.0)     32 (29.1) 

我做错了什么,我需要做什么才能获得 smd 输出?

呃……这个?

print(tabUnmatched, smd = TRUE)

                Stratified by group
                  healthy       sick          SMD   
  n                  90           110               
  age (mean (SD)) 49.18 (7.97)  49.72 (10.10)  0.059
  hair (%)                                     0.050
     black           30 (33.3)     35 (31.8)        
     blond           33 (36.7)     43 (39.1)        
     brown           27 (30.0)     32 (29.1)