Skip to contents

An object with class "summarizedFactors" is the input. Such an object should be created with the function rockchalk::summarizeFactors. Each element in that list is then organized for printing in a tabular summary. This should look almost like R's own summary function, except for the additional information that these factor summaries include.

Usage

formatSummarizedFactors(x, ...)

Arguments

x

A summarizedFactors object produced by summarizeFactors

...

optional arguments. Only value currently used is digits, which defaults to 2.

Value

A table of formatted output

Author

Paul E. Johnson pauljohn@ku.edu

Examples

dat <- data.frame(xcat1 = gl(10, 3), xcat2 = gl(5, 6))
summarizeFactors(dat, maxLevels = 8)
#> $xcat1
#> $xcat1$table
#>  1  2  3  4  5  6  7  8  9 10 
#>  3  3  3  3  3  3  3  3  3  3 
#> 
#> $xcat1$stats
#>          nobs         nmiss       entropy normedEntropy 
#>     30.000000      0.000000      3.321928      1.000000 
#> 
#> 
#> $xcat2
#> $xcat2$table
#> 1 2 3 4 5 
#> 6 6 6 6 6 
#> 
#> $xcat2$stats
#>          nobs         nmiss       entropy normedEntropy 
#>     30.000000      0.000000      2.321928      1.000000 
#> 
#> 
#> attr(,"class")
#> [1] "summarizedFactors"
#> attr(,"maxLevels")
#> [1] 8
#> attr(,"stats")
#> [1] "entropy"       "normedEntropy" "nobs"          "nmiss"        
#> attr(,"digits")
#> [1] 2
formatSummarizedFactors(summarizeFactors(dat))
#>                 xcat1                xcat2
#>  1           : 3      1: 6                
#>  2           : 3      2: 6                
#>  3           : 3      3: 6                
#>  4           : 3      4: 6                
#>  (All Others): 18     5: 6                
#>  nobs         : 30.0  nobs         : 30.0 
#>  nmiss        :  0.0  nmiss        :  0.0 
#>  entropy      :  3.3  entropy      :  2.3 
#>  normedEntropy:  1.0  normedEntropy:  1.0