4

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

Output: Descriptive Statistics by ID

+--------------------------+--------+--------+
|                          |HUSBAND |SELF    |
|                          |(N=28)  |(N=72)  |
+--------------------------+--------+--------+
|OCCUPATION : SELF EMPLOYED|93% (26)|31% (22)|
+--------------------------+--------+--------+

Compare this to the simple table()

        OCCUPATION
ID        OTHERS SELF EMPLOYED
  HUSBAND      2            26
  SELF        50            22
Jilber Urbina
  • 58,147
  • 10
  • 114
  • 138
user702432
  • 11,898
  • 21
  • 55
  • 70
  • I think something funky happens when print summary method calls `formatCats`. I'll try and get back to this a little later. – Roman Luštrik May 17 '13 at 08:24

1 Answers1

4

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)|
+-------------------+--------+--------+
user702432
  • 11,898
  • 21
  • 55
  • 70