3.3 covsum

covsum can be used to generate Table 1 style output for either the entire sample, or by specifying the maincov argument, by subgroups. Note the use of rm_covsum.

Typing ?covsum will provide a complete description of the covsum arguments. Here the most recent changes are highlighted.

rm_covsum(data=lung,
       covs=c('Status','wt.loss','OneLevelFactor'),
       digits=2,
       maincov = 'Sex',
       all.stats=TRUE,
       include_missing=T,
       percentage='row', 
       pvalue=FALSE)
Table 3.1: Summary sample statistics by Sex.
Covariate Full Sample (n=228) Female (n=86) Male (n=132) NA (n=10)
Status
0 63 36 (57) 24 (38) 3 (5)
1 165 50 (30) 108 (65) 7 (4)
wt loss
Mean (sd) 9.83 (13.14) 8.04 (13.36) 11.43 (13.19) 5.10 (7.14)
Median (Q1,Q3) 7.00 (0.00,15.75) 4 (0,11) 8 (1,20) 2.50 (0.00,12.50)
Range (min, max) (-24,68) (-24,52) (-13,68) (-3,15)
Missing 14 4 10 0
OneLevelFactor
one level 228 86 (38) 132 (58) 10 (4)

New Functionality & Bug Fixes

  • digits number of digits for summarizing numeric data
  • pvalue boolean indicating if you want p-values included in the table
  • full boolean indicating if the full sample column should be displayed
  • include_missing prints the number of values of the maincov missing and excluded from the table
  • percentage choice of how percentages are presented ,one of column (default) or row
  • show.tests option to display the statistical tests performed
  • all.tests option of showing both the IQR and the range on separate lines
  • excludeLevels option to exclude levels from covariates from association tests
  • Added functionality to test for small counts in contingency table and perform Fisher.exact if req’d
  • If testcont=T will perform unequal variance t-test for two groups
  • character variables are automatically converted to factors
  • function will now work with data imported from SPSS using haven package
  • function works as expected with factors containing only a single level
  • if median, Q1,Q3 (or Min/Max) are all integers decimals are not reported
  • NaN is no longer displayed, instead cells are empty
  • silenced the try function