r - 如何生成 Z 检验,包括 expss 列中的变量总数?
问题描述
其实是两个问题。
- 如何为 中的列中的变量添加总计
expss
? - 是否可以对列中的变量执行 Z 检验,包括作为不同类别的总计?
您可以在下面找到一段我会运行但没有用的代码...我的意思是我什至无法在列变量的右侧/左侧添加总计...
test_table = tab_significance_options(data = df, compare_type = "subtable", bonferroni = TRUE, subtable_marks = "both") %>%
tab_cells(VAR1) %>%
tab_total_statistic("w_cpct") %>%
tab_cols(VAR2) %>%
tab_stat_cpct() %>%
tab_cols(total(VAR2)) %>%
tab_last_sig_cpct() %>%
tab_pivot(stat_position = "outside_columns")
我将不胜感激任何建议。
解决方案
要与第一列进行比较,您需要在“compare_type”中另外指定“first_column”。其次,对于正确的结果,总统计量之一应该是案例。考虑到以上所有因素:
library(expss)
data(mtcars)
test_table = mtcars %>%
tab_significance_options(compare_type = c("first_column", "subtable"), bonferroni = TRUE, subtable_marks = "both") %>%
tab_total_statistic(c("u_cases", "w_cpct")) %>%
tab_cells(gear) %>%
tab_cols(total(am), am) %>%
tab_stat_cpct() %>%
tab_last_sig_cpct() %>%
tab_pivot()
test_table
# | | | #Total | am | |
# | | | | 0 | 1 |
# | | | | A | B |
# | ---- | ---------------- | ------ | -------- | -------- |
# | gear | 3 | 46.9 | 78.9 + | |
# | | 4 | 37.5 | 21.1 < B | 61.5 > A |
# | | 5 | 15.6 | | 38.5 |
# | | #Total cases | 32 | 19 | 13 |
# | | #Total wtd. cpct | 100 | 100 | 100 |
推荐阅读
- ruby-on-rails - 在旧版 Rails 应用程序中安装 webpacker
- flutter - Flutter 使用 Base64 或其他 MP3 编码器/解码器
- java - 如何在像whatsapp或skype这样的recyclerview中实现淡出stickyheader?
- java - 如何将数据加载到recyclerView
- c - 使用 GMenu 的菜单中的巨大差距
- angular - 如何使用 Firebase 在数组中推送新项目
- android - Flutter Firebase 错误 Null 资金(FirebaseUser)无法分配给参数,仪表类型 FutureOr
- c++ - 使用大括号进行实例化 - 它是什么以及为什么在这里使用它?
- css - 如何在 inline-flex 元素的一侧创建边距?
- python - Django:您正在使用 staticfiles 应用程序而没有将 STATIC_ROOT 设置设置为文件系统路径