set_opts: Set certain options

View source: R/set_opts.R

set_optsR Documentation

Set certain options

Description

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,
  raw = 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", "kableExtra", "flextable"; "screen". For the following output types, please also specify the file argument: "Excel", "Excel_v1", "Word", "CSV".

raw

print unformatted / raw values?

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.

    • Retain missing values – same as drop_na = 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.

    • Drop missing values – same as drop_na = 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", "kableExtra", "flextable": use this table-making package. Be sure that this package is installed.

  • "screen": print plain-text tables to the screen.

  • "Excel", "Excel_v1": print to an Excel workbook. Please specify the name of an Excel file using the file argument. Before using Excel printing, please be sure to install these packages: openxlsx2 and mschart.

  • "Word": print to a Word document. Please specify the name of a Word file using the file argument. Before using Word printing, please be sure to install these packages: flextable and officer.

  • "CSV": print to a comma-separated values (CSV) file. Please specify the name of a CSV file using the file argument.

raw = TRUE prints unformatted / raw values. This is useful for getting lots of significant digits. It is supported with output = "screen", output = "CSV", and output = "Excel". Also see as.data.frame.astra_table() and restructure().

Value

(Nothing.)

See Also

Other options: set_survey(), show_options(), surveytable-options

Other print: as.data.frame.astra_table(), print.astra_table(), restructure()

Examples

set_survey(namcs2019sv)

# Round counts to the nearest one thousand:
set_opts(count = "1k")
tab("AGER")
set_opts(count = "int")

show_opts()

surveytable documentation built on Aug. 20, 2026, 1:08 a.m.