set_opts()
sets certain package 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(
reset = NULL,
mode = NULL,
adj = NULL,
output = NULL,
file = NULL,
.file_temp = NULL,
count = NULL,
lpe = NULL,
drop_na = NULL,
max_levels = NULL
)
show_opts()
Arguments
- reset
reset all options to their default values?
- mode
"general"
or"NCHS"
. See below for details.- adj
adjustment to the Korn and Graubard confidence intervals for proportions. See
svyciprop_adjusted()
for details.- output
specify how the output is printed:
"auto"
(default);"huxtable"
,"gt"
, or"kableExtra"
;"raw"
;"Excel"
or"CSV"
. Ifoutput
is"Excel"
or"CSV"
, must also specifyfile
. Ifoutput
is"Excel"
, be sure to installopenxlsx2
andmschart
.- file
file name (see
output
).- .file_temp
place
file
in a temporary folder?- 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.
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 – same as
adj = "none"
.
"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 – same as
adj = "nchs"
. This is appropriate for some, but not all, NCHS data systems. For some NCHS data systems, such as NHIS, you might need to setadj
to one of the other values.
adj
specifies the adjustment to the Korn and Graubard confidence intervals for
proportions. See svyciprop_adjusted()
for details.
output
determines how the output is printed:
"auto"
(default): automatically select the table-making package, depending on the destination (such as screen, HTML, or PDF / LaTeX)."huxtable"
,"gt"
, or"kableExtra"
: use this table-making package. Be sure that this package is installed."raw"
: unformatted / raw output. This is useful for getting lots of significant digits."Excel"
: print to an Excel workbook. Please specify the name of an Excel file using thefile
argument. Before using Excel printing, please be sure to install these packages:openxlsx2
andmschart
."CSV"
: print to a comma-separated values (CSV) file. Please specify the name of a CSV file using thefile
argument.
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) │
#> └───────────┴──────────────┴────────────────────────────────────────────────┘
#>
# Round counts to the nearest one thousand:
set_opts(count = "1k")
#> * Rounding counts to the nearest thousand.
tab("AGER")
#> Patient age recode {NAMCS 2019 PUF}
#> ┌─────────────┬───────┬─────────────┬──────────┬──────────┬──────────┬─────────┬─────┬──────┬──────┐
#> │ Level │ n │ Number..000 │ SE..000. │ LL..000. │ UL..000. │ Percent │ SE │ LL │ UL │
#> │ │ │ . │ │ │ │ │ │ │ │
#> ├─────────────┼───────┼─────────────┼──────────┼──────────┼──────────┼─────────┼─────┼──────┼──────┤
#> │ Under 15 │ 887 │ 117,917 │ 14,097 │ 93,229 │ 149,142 │ 11.4 │ 1.3 │ 8.9 │ 14.2 │
#> │ years │ │ │ │ │ │ │ │ │ │
#> ├─────────────┼───────┼─────────────┼──────────┼──────────┼──────────┼─────────┼─────┼──────┼──────┤
#> │ 15-24 years │ 542 │ 64,856 │ 7,018 │ 52,387 │ 80,292 │ 6.3 │ 0.6 │ 5.1 │ 7.5 │
#> ├─────────────┼───────┼─────────────┼──────────┼──────────┼──────────┼─────────┼─────┼──────┼──────┤
#> │ 25-44 years │ 1,435 │ 170,271 │ 13,966 │ 144,925 │ 200,049 │ 16.4 │ 1.1 │ 14.3 │ 18.8 │
#> ├─────────────┼───────┼─────────────┼──────────┼──────────┼──────────┼─────────┼─────┼──────┼──────┤
#> │ 45-64 years │ 2,283 │ 309,506 │ 23,290 │ 266,994 │ 358,787 │ 29.9 │ 1.4 │ 27.2 │ 32.6 │
#> ├─────────────┼───────┼─────────────┼──────────┼──────────┼──────────┼─────────┼─────┼──────┼──────┤
#> │ 65-74 years │ 1,661 │ 206,866 │ 14,366 │ 180,481 │ 237,109 │ 20 │ 1.2 │ 17.6 │ 22.5 │
#> ├─────────────┼───────┼─────────────┼──────────┼──────────┼──────────┼─────────┼─────┼──────┼──────┤
#> │ 75 years │ 1,442 │ 167,069 │ 15,179 │ 139,746 │ 199,735 │ 16.1 │ 1.3 │ 13.7 │ 18.8 │
#> │ and over │ │ │ │ │ │ │ │ │ │
#> └─────────────┴───────┴─────────────┴──────────┴──────────┴──────────┴─────────┴─────┴──────┴──────┘
#> N = 8250.
#>
set_opts(count = "int")
#> * Rounding counts to the nearest integer.
show_opts()
#> * Korn and Graubard confidence intervals for proportions.
#> * Printing with huxtable for screen, gt for HTML, or kableExtra for PDF.
#> * Rounding counts to the nearest integer.
#> * Not identifying low-precision estimates.
#> * Retaining missing values.
#> * Maximum number of levels is: 20