harrelfe / Hmisc

Harrell Miscellaneous
Other
208 stars 81 forks source link

Describe Function Behavior Change v4.0 #62

Open afgithub2000 opened 7 years ago

afgithub2000 commented 7 years ago

Dr Harrell, I have been using the describe function to generate frequency reports for survey data. It looks like the object output has changed with with version 4.0 of the package. For example, I have 7 level variable (1-7). In version 3.x the output was a frequency table. With Version 4.0 it is a list that is used if there 20+ levels. Is there a way to revert to the old object/output? I looked in the help file and couldn't see an option.

FYI, I wrote a custom process to output the results to a CSV file based on the describe function. The new way breaks the process. I am going to have to load the old version of the package so I can finish a report on a new survey.

Old way - Hmisc_3.17-4

> Hmisc::describe(ns16$s5_race, digits = 3)# calculate object
ns16$s5_race 
      n missing  unique    Info    Mean 
   2991       9       7    0.57    1.59 

             1   2  3   4 5  6  7
Frequency 2246 364 44 209 9 60 59
%           75  12  1   7 0  2  2

New Way - Hmisc_4.0-0

> Hmisc::describe(ns16$s5_race, digits = 3)# calculate object
ns16$s5_race 
       n  missing distinct     Info     Mean      Gmd 
    2991        9        7    0.574     1.59    0.994 

lowest : 1 2 3 4 5, highest: 3 4 5 6 7 

1 (2246, 0.751), 2 (364, 0.122), 3 (44, 0.015), 4 (209, 0.070), 5 (9, 0.003), 6 (60, 0.020), 7 (59,
0.020)
harrelfe commented 7 years ago

The summary statistics will remain as they are in 4.0-0 but for 4.0-1, I have improved the logic so that you'll get the old format for the frequencies as a table, except that % is replaced by Proportion. I've committed these changes in case you want to get the new source for describe.s.