How to force Hmisc::describe to display frequencies?

492 views Asked by At

describe(letters[1:19]) outputs a table of frequencies but describe(letters[1:20]) does not. I tried setting listunique=10^7 and listnchar=0 but that didn't help.

http://cran.r-project.org/web/packages/Hmisc/Hmisc.pdf

1

There are 1 answers

0
IRTFM On BEST ANSWER

I've wondered about that for years and never succeeded in getting Hmisc::describe to honor that parameter (despite using Hmisc extensively). Here's what I would do to get something similar:

 print(rbind( count = as.character(table(letters[1:20])),  
              pct = 100*prop.table(table(letters[1:20]) ) ), 
           quote=FALSE)
#-----------------------------
      a b c d e f g h i j k l m n o p q r s t
count 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
pct   5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5

You may want to format() the pct to round to a certain number (0 or 1) of decimal places.