摘要{Hmisc}掉落类别? [英] summary {Hmisc} drops category?

查看:70
本文介绍了摘要{Hmisc}掉落类别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用此文件使用百分比获取交叉表 code> Hmisc 。但是,为什么 summary()从变量OCCUPATION删除类别( OTHERS)?

I am trying to get a crosstab with percentages from this file using Hmisc. But why is summary() dropping a category ("OTHERS") from the variable OCCUPATION?

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

输出:
按ID的描述性统计

Output: Descriptive Statistics by 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 选项:

This is for the benefit of whoever has faced this peculiar problem. I stumbled across the solution after going over the very, very long documentation that Hmisc has. The solution is to use print() with exclude1=F option:

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)|
+-------------------+--------+--------+

这篇关于摘要{Hmisc}掉落类别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆