【问题标题】:totals = FALSE still outputs totals in R package summarytools ctable()?totals = FALSE 仍然在 R 包 summarytools ctable() 中输出总数?
【发布时间】:2019-05-03 19:14:37
【问题描述】:

任何使用 R 包 summarytools 的人都遇到过这个问题?我已经设置了全局 summarytools 选项来抑制 ctables 中的总计:

st_options(ctable.totals=FALSE)

我在函数调用中也调用了同样的方法:

with(df, ctable(
    gender,
    var2,
    chisq = F,
    headings = T,
    totals = FALSE
  )

但它仍然会在实际的 cross_table 表数据中输出总计。有没有人找到抑制这种情况的方法?

【问题讨论】:

  • 我测试了这段代码with(mtcars, ctable( vs, am, chisq = F, headings = T, totals = F ) ) 并没有显示总数。
  • 总数未显示在呈现的输出中 - 您是否在交叉表本身中看到它们?
  • 这是我的输出:pastebin.com/7QyNSGJR

标签: r summarytools


【解决方案1】:

此问题已在更高版本的 summarytools 中得到修复。

with(tobacco, ctable(
  gender,
  smoker,
  chisq = F,
  headings = T,
  totals = FALSE
))

## Cross-Tabulation, Row Proportions  
## gender * smoker  
## Data Frame: tobacco  
## 
## -------- -------- ------------- -------------
##            smoker           Yes            No
##   gender                                     
##        F            147 (30.1%)   342 (69.9%)
##        M            143 (29.2%)   346 (70.8%)
##     <NA>              8 (36.4%)    14 (63.6%)
## -------- -------- ------------- -------------

【讨论】:

    【解决方案2】:

    我从 Github 上的开发人员那里收到一条消息,说这实际上是一个预期的功能,如果我们想从交叉表中删除它,我们必须手动完成。谢谢马可!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-13
      • 1970-01-01
      • 1970-01-01
      • 2013-05-19
      • 1970-01-01
      • 2018-02-01
      • 2020-07-13
      • 1970-01-01
      相关资源
      最近更新 更多