Skip to contents

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,
  count = NULL,
  lpe = NULL,
  drop_na = NULL,
  max_levels = NULL,
  csv = 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

how the output is printed: "auto" (default); "huxtable", "gt", or "kableExtra"; or "raw".

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.

Value

(Nothing.)

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 set adj 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.

See also

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()
#> * 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
#> * CSV output has been turned off.