3

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

kevinykuo
  • 4,600
  • 5
  • 23
  • 31
  • It does give you a frequency table of sorts, but oriented vertically rather than horizontally. Try, e.g., `describe(rep(letters[1:20],7), listunique=20, listnchar=0)`. If you want a horizontal table, it looks like you're going to have to hack the code in `describe.vector()` beginning around the line reading `if (n.unique >= 20) {`. The cutoff between horizontal and vertical "tables" looks to be pretty well hardcoded into that function. – Josh O'Brien Dec 02 '13 at 21:49

1 Answers1

1

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.

IRTFM
  • 258,963
  • 21
  • 364
  • 487