If a tabulation function is called from the top level, it should print out
its table(s) on its own. If that tabulation function is called not from the
top level, such as from within a loop or another function, you need to call
print()
explicitly. For example:
Details
The package used to produce the tables can be changed – see the output
argument
of set_opts()
for details. By default, the table-making package huxtable
is used.
See also
Other print:
save_excel()
Examples
set_survey(namcs2019sv)
#> Survey info {NAMCS 2019 PUF}
#> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
#> │ Variables │ Observations │ Design │
#> ├───────────┼──────────────┼────────────────────────────────────────────────┤
#> │ 33 │ 8,250 │ Stratified 1 - level Cluster Sampling design │
#> │ │ │ (with replacement) │
#> │ │ │ With (398) clusters. │
#> │ │ │ namcs2019sv = survey::svydesign(ids = ~CPSUM, │
#> │ │ │ strata = ~CSTRATM, weights = ~PATWT │
#> │ │ │ , data = namcs2019sv_df) │
#> └───────────┴──────────────┴────────────────────────────────────────────────┘
#>
table1 = tab("AGER")
print(table1)
#> Patient age recode {NAMCS 2019 PUF}
#> ┌─────────────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐
#> │ Level │ n │ Number │ SE │ LL │ UL │ Percent │ SE │ LL │ UL │
#> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤
#> │ Under 15 │ 887 │ 117,916,772 │ 14,097,315 │ 93,228,928 │ 149,142,177 │ 11.4 │ 1.3 │ 8.9 │ 14.2 │
#> │ years │ │ │ │ │ │ │ │ │ │
#> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤
#> │ 15-24 years │ 542 │ 64,855,698 │ 7,018,359 │ 52,386,950 │ 80,292,164 │ 6.3 │ 0.6 │ 5.1 │ 7.5 │
#> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤
#> │ 25-44 years │ 1,435 │ 170,270,604 │ 13,965,978 │ 144,924,545 │ 200,049,472 │ 16.4 │ 1.1 │ 14.3 │ 18.8 │
#> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤
#> │ 45-64 years │ 2,283 │ 309,505,956 │ 23,289,827 │ 266,994,092 │ 358,786,727 │ 29.9 │ 1.4 │ 27.2 │ 32.6 │
#> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤
#> │ 65-74 years │ 1,661 │ 206,865,982 │ 14,365,993 │ 180,480,708 │ 237,108,637 │ 20 │ 1.2 │ 17.6 │ 22.5 │
#> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤
#> │ 75 years │ 1,442 │ 167,069,344 │ 15,179,082 │ 139,746,193 │ 199,734,713 │ 16.1 │ 1.3 │ 13.7 │ 18.8 │
#> │ and over │ │ │ │ │ │ │ │ │ │
#> └─────────────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘
#> N = 8250.
#>
table_many = tab("MDDO", "SPECCAT", "MSA")
print(table_many)
#> Type of doctor (MD or DO) {NAMCS 2019 PUF}
#> ┌─────────────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐
#> │ Level │ n │ Number │ SE │ LL │ UL │ Percent │ SE │ LL │ UL │
#> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤
#> │ M.D. - │ 7,498 │ 980,280,219 │ 48,387,921 │ 889,841,831 │ 1,079,910,2 │ 94.6 │ 0.7 │ 93.1 │ 95.8 │
#> │ Doctor of │ │ │ │ │ 43 │ │ │ │ │
#> │ Medicine │ │ │ │ │ │ │ │ │ │
#> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤
#> │ D.O. - │ 752 │ 56,204,137 │ 6,601,909 │ 44,596,891 │ 70,832,404 │ 5.4 │ 0.7 │ 4.2 │ 6.9 │
#> │ Doctor of │ │ │ │ │ │ │ │ │ │
#> │ Osteopathy │ │ │ │ │ │ │ │ │ │
#> └─────────────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘
#> N = 8250.
#>
#> Type of specialty (Primary, Medical, Surgical) {NAMCS 2019 PUF}
#> ┌─────────────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐
#> │ Level │ n │ Number │ SE │ LL │ UL │ Percent │ SE │ LL │ UL │
#> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤
#> │ Primary │ 2,993 │ 521,466,378 │ 31,136,212 │ 463,840,192 │ 586,251,877 │ 50.3 │ 2.6 │ 45.1 │ 55.5 │
#> │ care │ │ │ │ │ │ │ │ │ │
#> │ specialty │ │ │ │ │ │ │ │ │ │
#> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤
#> │ Surgical │ 3,050 │ 214,831,829 │ 31,110,335 │ 161,661,415 │ 285,489,984 │ 20.7 │ 3 │ 15.1 │ 27.3 │
#> │ care │ │ │ │ │ │ │ │ │ │
#> │ specialty │ │ │ │ │ │ │ │ │ │
#> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤
#> │ Medical │ 2,207 │ 300,186,150 │ 43,496,739 │ 225,806,019 │ 399,066,973 │ 29 │ 3.6 │ 22.1 │ 36.6 │
#> │ care │ │ │ │ │ │ │ │ │ │
#> │ specialty │ │ │ │ │ │ │ │ │ │
#> └─────────────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘
#> N = 8250.
#>
#> Metropolitan Statistical Area Status of physician location {NAMCS 2019 PUF}
#> ┌─────────────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐
#> │ Level │ n │ Number │ SE │ LL │ UL │ Percent │ SE │ LL │ UL │
#> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤
#> │ MSA │ 7,496 │ 973,675,566 │ 50,514,928 │ 879,490,192 │ 1,077,947,3 │ 93.9 │ 1.7 │ 89.6 │ 96.8 │
#> │ (Metropolit │ │ │ │ │ 34 │ │ │ │ │
#> │ an │ │ │ │ │ │ │ │ │ │
#> │ Statistical │ │ │ │ │ │ │ │ │ │
#> │ Area) │ │ │ │ │ │ │ │ │ │
#> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤
#> │ Non-MSA │ 754 │ 62,808,790 │ 17,549,184 │ 36,248,698 │ 108,829,955 │ 6.1 │ 1.7 │ 3.2 │ 10.4 │
#> └─────────────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘
#> N = 8250.
#>