gpt4 book ai didi

r - 摘要 {Hmisc} 丢弃类别?

转载 作者:行者123 更新时间:2023-12-01 01:08:50 29 4
gpt4 key购买 nike

我正在尝试从 this file 中获取带有百分比的交叉表使用 Hmisc .但为什么是summary()从变量 OCCUPATION 中删除类别(“OTHERS”)?

library(Hmisc)
summary(ID ~ OCCUPATION, data=df, method="reverse")

输出:
按 ID 的描述性统计
+--------------------------+--------+--------+
| |HUSBAND |SELF |
| |(N=28) |(N=72) |
+--------------------------+--------+--------+
|OCCUPATION : SELF EMPLOYED|93% (26)|31% (22)|
+--------------------------+--------+--------+

将此与简单的 table() 进行比较
        OCCUPATION
ID OTHERS SELF EMPLOYED
HUSBAND 2 26
SELF 50 22

最佳答案

这是为了任何遇到这个特殊问题的人的利益。在浏览了 Hmisc 的非常非常长的文档后,我偶然发现了该解决方案。已。解决方法是使用print()exclude1=F选项:

print(summary(ID ~ OCCUPATION, data=df, method="reverse"), exclude1=F)



Descriptive Statistics by ID

+-------------------+--------+--------+
| |HUSBAND |SELF |
| |(N=28) |(N=72) |
+-------------------+--------+--------+
|OCCUPATION : OTHERS| 7% ( 2)|69% (50)|
+-------------------+--------+--------+
| SELF EMPLOYED |93% (26)|31% (22)|
+-------------------+--------+--------+

关于r - 摘要 {Hmisc} 丢弃类别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16602877/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com