set_opts()
sets certain options. To view these options, use show_opts()
.
For more advanced control and detailed customization, experienced users can
also employ options()
and show_options()
(refer to surveytable-options
for further information).
Usage
set_opts(
mode = NULL,
count = NULL,
lpe = NULL,
drop_na = NULL,
max_levels = NULL,
csv = NULL,
output = NULL
)
show_opts()
Arguments
- mode
"general"
or"NCHS"
. See below for details.- count
round counts to the nearest: integer (
"int"
) or one thousand ("1k"
)- lpe
identify low-precision estimates?
- drop_na
drop missing values (
NA
)? Categorical variables only.- max_levels
a categorical variable can have at most this many levels. Used to avoid printing huge tables.
- csv
name of a CSV file or
""
to turn off CSV output.- output
package to use for printing. One of
"huxtable"
,"gt"
, or"kableExtra"
. For the last two, be sure that this package is installed."auto"
(default) = automatically selecthuxtable
for screen,gt
for HTML, orkableExtra
for PDF (LaTeX).
Details
If you are not setting a particular option, leave it as NULL
.
mode
can be either "general"
or "NCHS"
and has the following meaning:
"general"
:Round counts to the nearest integer -- same as
count = "int"
.Do not look for low-precision estimates -- same as
lpe = FALSE
.Percentage CI's: use standard Korn-Graubard CI's.
"nchs"
:Round counts to the nearest 1,000 -- same as
count = "1k"
.Identify low-precision estimates -- same as
lpe = TRUE
.Percentage CI's: adjust Korn-Graubard CI's for the number of degrees of freedom, matching the SUDAAN calculation. NHIS users, be sure to also type
options(surveytable.adjust_svyciprop.df_method = "NHIS")
.
See also
Other options:
set_survey()
,
show_options()
,
surveytable-options
Examples
# Send output to a CSV file:
file_name = tempfile(fileext = ".csv")
suppressMessages( set_opts(csv = file_name) )
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) │
#> └───────────┴──────────────┴────────────────────────────────────────────────┘
#>
tab("AGER")
#> 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.
#>
set_opts(csv = "") # Turn off CSV output
#> * Turning off CSV output.
show_opts()
#> * Rounding counts to the nearest integer.
#> * Not identifying low-precision estimates.
#> * Using standard Korn-Graubard CI's.
#> * Retaining missing values.
#> * Maximum number of levels is: 20
#> * CSV output has been turned off.
#> * Printing with huxtable for screen, gt for HTML, or kableExtra for PDF.