Skip to contents

This functions builds a dataframe that gather most relevant information from a crossvar object. Useful in reports, associated with kableExtra or other tables output generating engine.

Usage

table_crossvar(x, round_digits = 3, counts_and = c("props", "target%"))

Arguments

x

crossvar - crossvar object (stored in targeter$profiles slot).

round_digits

integer - number of digits to rounds some values.

counts_and

- character - output will always contain counts, we can add row percentages and column percentage for target (both always by default)

Value

a data.frame

Examples

tar <- targeter(adult, target = 'ABOVE50K')
#> 
#> INFO:target ABOVE50K detected as type: binary
#> INFO:binary target contains number, automatic chosen level: 1; override using `target_reference_level`
table_crossvar(tar$profiles[['EDUCATION']])
#>                 N0   N1  Ntot   perc0   perc1 target%
#>  10th          871   62   933 93.355%  6.645%  0.791%
#>  11th         1115   60  1175 94.894%  5.106%  0.765%
#>  12th          400   33   433 92.379%  7.621%  0.421%
#>  1st-4th       162    6   168 96.429%  3.571%  0.077%
#>  5th-6th       317   16   333 95.195%  4.805%  0.204%
#>  7th-8th       606   40   646 93.808%  6.192%   0.51%
#>  9th           487   27   514 94.747%  5.253%  0.344%
#>  Assoc-acdm    802  265  1067 75.164% 24.836%   3.38%
#>  Assoc-voc    1021  361  1382 73.878% 26.122%  4.604%
#>  Bachelors    3134 2221  5355 58.525% 41.475% 28.325%
#>  Doctorate     107  306   413 25.908% 74.092%  3.903%
#>  HS-grad      8826 1675 10501 84.049% 15.951% 21.362%
#>  Masters       764  959  1723 44.341% 55.659% 12.231%
#>  Preschool      51    0    51    100%      0%      0%
#>  Prof-school   153  423   576 26.562% 73.438%  5.395%
#>  Some-college 5904 1387  7291 80.977% 19.023% 17.689%