From 5efac90dec4a55d14b612c053c1fd228130d5b04 Mon Sep 17 00:00:00 2001 From: Alex Strashny Date: Mon, 16 Sep 2024 15:13:18 -0400 Subject: [PATCH] set_opts --- DESCRIPTION | 3 +- NAMESPACE | 3 +- NEWS.md | 4 +- R/deprecated.R | 39 +++ R/set_count.R | 60 ---- R/set_mode.R | 31 -- R/set_opts.R | 179 ++++++++++ R/set_output.R | 86 ----- R/set_survey.R | 25 +- R/surveytable.R | 8 +- R/svyciprop_adjusted.R | 6 +- R/tab.R | 2 +- R/z_utils.R | 8 + R/zzz.R | 47 ++- README.md | 1 - _pkgdown.yml | 3 +- docs/articles/Advanced-topics.html | 3 +- ...tory-Medical-Care-Survey-NAMCS-tables.html | 19 +- ...ty-Services-User-NSLTCP-RCC-SU-report.html | 5 +- docs/articles/surveytable.html | 320 ++---------------- docs/index.html | 3 +- docs/news/index.html | 5 +- docs/pkgdown.yml | 2 +- docs/reference/codebook.html | 2 - docs/reference/deprecated.html | 101 ++++++ docs/reference/figures/lifecycle-archived.svg | 21 ++ docs/reference/figures/lifecycle-defunct.svg | 21 ++ .../figures/lifecycle-deprecated.svg | 21 ++ .../figures/lifecycle-experimental.svg | 21 ++ docs/reference/figures/lifecycle-maturing.svg | 21 ++ .../figures/lifecycle-questioning.svg | 21 ++ .../figures/lifecycle-soft-deprecated.svg | 21 ++ docs/reference/figures/lifecycle-stable.svg | 29 ++ .../figures/lifecycle-superseded.svg | 21 ++ docs/reference/index.html | 11 +- docs/reference/print.surveytable_table.html | 1 - docs/reference/set_count_1k.html | 155 --------- docs/reference/set_opts.html | 208 ++++++++++++ docs/reference/set_output.html | 151 --------- docs/reference/set_survey.html | 45 ++- docs/reference/show_options.html | 3 +- docs/reference/survey_subset.html | 1 - docs/reference/surveytable-options.html | 11 +- docs/reference/svyciprop_adjusted.html | 7 +- docs/reference/tab.html | 1 - docs/reference/tab_rate.html | 1 - docs/reference/tab_subset.html | 1 - docs/reference/tab_subset_rate.html | 1 - docs/reference/total.html | 1 - docs/reference/total_rate.html | 1 - docs/reference/var_all.html | 1 - docs/reference/var_any.html | 1 - docs/reference/var_case.html | 1 - docs/reference/var_collapse.html | 1 - docs/reference/var_copy.html | 1 - docs/reference/var_cross.html | 1 - docs/reference/var_cut.html | 1 - docs/reference/var_list.html | 1 - docs/reference/var_not.html | 1 - docs/search.json | 2 +- docs/sitemap.xml | 8 +- inst/WORDLIST | 2 + man/deprecated.Rd | 26 ++ man/figures/lifecycle-archived.svg | 21 ++ man/figures/lifecycle-defunct.svg | 21 ++ man/figures/lifecycle-deprecated.svg | 21 ++ man/figures/lifecycle-experimental.svg | 21 ++ man/figures/lifecycle-maturing.svg | 21 ++ man/figures/lifecycle-questioning.svg | 21 ++ man/figures/lifecycle-soft-deprecated.svg | 21 ++ man/figures/lifecycle-stable.svg | 29 ++ man/figures/lifecycle-superseded.svg | 21 ++ man/set_count_1k.Rd | 39 --- man/set_opts.Rd | 76 +++++ man/set_output.Rd | 38 --- man/set_survey.Rd | 35 +- man/show_options.Rd | 3 +- man/surveytable-options.Rd | 11 +- man/svyciprop_adjusted.Rd | 6 +- ...atory-Medical-Care-Survey-NAMCS-tables.Rmd | 11 +- ...ity-Services-User-NSLTCP-RCC-SU-report.Rmd | 2 +- vignettes/surveytable.Rmd | 24 +- 82 files changed, 1209 insertions(+), 1041 deletions(-) create mode 100644 R/deprecated.R delete mode 100644 R/set_count.R delete mode 100644 R/set_mode.R create mode 100644 R/set_opts.R delete mode 100644 R/set_output.R create mode 100644 docs/reference/deprecated.html create mode 100644 docs/reference/figures/lifecycle-archived.svg create mode 100644 docs/reference/figures/lifecycle-defunct.svg create mode 100644 docs/reference/figures/lifecycle-deprecated.svg create mode 100644 docs/reference/figures/lifecycle-experimental.svg create mode 100644 docs/reference/figures/lifecycle-maturing.svg create mode 100644 docs/reference/figures/lifecycle-questioning.svg create mode 100644 docs/reference/figures/lifecycle-soft-deprecated.svg create mode 100644 docs/reference/figures/lifecycle-stable.svg create mode 100644 docs/reference/figures/lifecycle-superseded.svg delete mode 100644 docs/reference/set_count_1k.html create mode 100644 docs/reference/set_opts.html delete mode 100644 docs/reference/set_output.html create mode 100644 man/deprecated.Rd create mode 100644 man/figures/lifecycle-archived.svg create mode 100644 man/figures/lifecycle-defunct.svg create mode 100644 man/figures/lifecycle-deprecated.svg create mode 100644 man/figures/lifecycle-experimental.svg create mode 100644 man/figures/lifecycle-maturing.svg create mode 100644 man/figures/lifecycle-questioning.svg create mode 100644 man/figures/lifecycle-soft-deprecated.svg create mode 100644 man/figures/lifecycle-stable.svg create mode 100644 man/figures/lifecycle-superseded.svg delete mode 100644 man/set_count_1k.Rd create mode 100644 man/set_opts.Rd delete mode 100644 man/set_output.Rd diff --git a/DESCRIPTION b/DESCRIPTION index e00d84d..22fd299 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -28,7 +28,8 @@ LazyDataCompression: bzip2 Imports: assertthat, huxtable, - kableExtra, + kableExtra, + lifecycle, magrittr, survey Suggests: diff --git a/NAMESPACE b/NAMESPACE index a6896e3..f6bd893 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -6,10 +6,11 @@ export(codebook) export(set_count_1k) export(set_count_int) export(set_mode) +export(set_opts) export(set_output) export(set_survey) export(show_options) -export(show_output) +export(show_opts) export(survey_subset) export(svyciprop_adjusted) export(tab) diff --git a/NEWS.md b/NEWS.md index 9a92716..4b3b7be 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,7 @@ # surveytable (development version) -* `rccsu2018` -* `set_mode()` +* Another public use data file for use in examples: `rccsu2018`. +* `set_opts()` replaces several other functions for setting options. # surveytable 0.9.4 diff --git a/R/deprecated.R b/R/deprecated.R new file mode 100644 index 0000000..6de2327 --- /dev/null +++ b/R/deprecated.R @@ -0,0 +1,39 @@ +#' Deprecated functions +#' +#' `r lifecycle::badge("deprecated")` +#' +#' Use [set_opts()] instead of any of the following: `set_mode()`, `set_count_1k()`, +#' `set_count_int()`, `set_output()`. +#' +#' @export +#' @keywords internal +#' @name deprecated +#' @rdname deprecated +set_mode = function(mode = "general") { + lifecycle::deprecate_soft("0.9.5", "set_mode()", "set_opts()") + set_opts(mode = mode) +} + +#' @export +#' @keywords internal +#' @rdname deprecated +set_count_1k = function() { + lifecycle::deprecate_soft("0.9.5", "set_count_1k()", "set_opts()") + set_opts(count = "1k") +} + +#' @export +#' @keywords internal +#' @rdname deprecated +set_count_int = function() { + lifecycle::deprecate_soft("0.9.5", "set_count_int()", "set_opts()") + set_opts(count = "int") +} + +#' @export +#' @keywords internal +#' @rdname deprecated +set_output = function(drop_na = NULL, max_levels = NULL, csv = NULL) { + lifecycle::deprecate_soft("0.9.5", "set_output()", "set_opts()") + set_opts(drop_na = drop_na, max_levels = max_levels, csv = csv) +} diff --git a/R/set_count.R b/R/set_count.R deleted file mode 100644 index 94b79e3..0000000 --- a/R/set_count.R +++ /dev/null @@ -1,60 +0,0 @@ -#' Rounding counts -#' -#' Determines how counts should be rounded. -#' -#' * `set_count_1k()`: round counts to the nearest 1,000. -#' * `set_count_int()`: round counts to the nearest integer. -#' -#' @return (Nothing.) -#' @family options -#' @export -#' -#' @examples -#' set_survey(namcs2019sv) -#' set_count_int() -#' total() -#' -#' set_count_1k() -#' total() -set_count_1k = function() { - # If making changes, update .onLoad() and set_survey() - options( - surveytable.tx_count = ".tx_count_1k" - , surveytable.names_count = c("n", "Number (000)", "SE (000)", "LL (000)", "UL (000)") - ) - message(paste0("* Rounding counts to the nearest 1,000." - , "\n* ?set_count_1k for other options.")) -} - -#' @rdname set_count_1k -#' @export -set_count_int = function() { - options( - surveytable.tx_count = ".tx_count_int" - , surveytable.names_count = c("n", "Number", "SE", "LL", "UL") - ) - message(paste0("* Rounding counts to the nearest integer." - , "\n* ?set_count_int for other options.")) -} - -.tx_count_1k = function(x) { - ## Huge UL -> Inf - x$rat = x$ul / x$x - idx = which(x$rat > 4e3) - x$ul[idx] = Inf - x$rat = NULL - - round(x / 1e3) -} -.tx_count_int = function(x) { - ## Huge UL -> Inf - x$rat = x$ul / x$x - idx = which(x$rat > 4e3) - x$ul[idx] = Inf - x$rat = NULL - - round(x) -} -.tx_count_none = function(x) { - x -} diff --git a/R/set_mode.R b/R/set_mode.R deleted file mode 100644 index a54212f..0000000 --- a/R/set_mode.R +++ /dev/null @@ -1,31 +0,0 @@ -#' @rdname set_survey -#' @order 2 -#' @export -set_mode = function(mode = "default") { - opts.table = c("nchs", "default", "general") - idx = mode %>% tolower %>% pmatch(opts.table) - assert_that(noNA(idx), msg = paste("Unknown mode:", mode)) - opts = opts.table[idx] - - if (opts == "nchs") { - message("* Mode: NCHS.") - options( - surveytable.tx_count = ".tx_count_1k" - , surveytable.names_count = c("n", "Number (000)", "SE (000)", "LL (000)", "UL (000)") - , surveytable.find_lpe = TRUE - , surveytable.adjust_svyciprop = TRUE - ) - } else if (opts %in% c("general", "default")) { - message("* Mode: General.") - options( - surveytable.tx_count = ".tx_count_int" - , surveytable.names_count = c("n", "Number", "SE", "LL", "UL") - , surveytable.find_lpe = FALSE - , surveytable.adjust_svyciprop = FALSE - ) - } else { - stop("!!") - } - - invisible(NULL) -} diff --git a/R/set_opts.R b/R/set_opts.R new file mode 100644 index 0000000..17ee58a --- /dev/null +++ b/R/set_opts.R @@ -0,0 +1,179 @@ +#' Set certain options +#' +#' `set_opts()` sets certain options. `show_opts()` shows the options that have +#' been set. More advanced users can also use [options()] and [show_options()] for +#' more detailed control. +#' +#' 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. +#' +#' @param mode `"general"` or `"NCHS"`. See below for details. +#' @param count round counts to the nearest: integer (`"int"`) or one thousand (`"1k"`) +#' @param lpe identify low-precision estimates? +#' @param drop_na drop missing values (`NA`)? Categorical variables only. +#' @param max_levels a categorical variable can have at most this many levels. Used to avoid printing huge tables. +#' @param csv name of a CSV file or `""` to turn off CSV output +#' +#' @return (Nothing.) +#' @family options +#' @export +#' +#' @examples +#' # Send output to a CSV file: +#' file_name = tempfile(fileext = ".csv") +#' suppressMessages( set_opts(csv = file_name) ) +#' set_survey(namcs2019sv) +#' tab("AGER") +#' set_opts(csv = "") # Turn off CSV output +#' +#' show_opts() +set_opts = function( + mode = NULL + , count = NULL + , lpe = NULL + , drop_na = NULL, max_levels = NULL, csv = NULL) { + # If making changes, update .onLoad() + + ## Mode has to go ahead of the other options + if (!is.null(mode)) { + mode %<>% .mymatch(c("nchs", "general")) + if (mode == "nchs") { + message("* Mode: NCHS.") + options(surveytable.tx_count = ".tx_count_1k" + , surveytable.names_count = c("n", "Number (000)", "SE (000)", "LL (000)", "UL (000)") + , surveytable.find_lpe = TRUE + , surveytable.adjust_svyciprop = TRUE) + } else if (mode == "general") { + message("* Mode: General.") + options(surveytable.tx_count = ".tx_count_int" + , surveytable.names_count = c("n", "Number", "SE", "LL", "UL") + , surveytable.find_lpe = FALSE + , surveytable.adjust_svyciprop = FALSE) + } + } + + if (!is.null(count)) { + count %<>% .mymatch(c("int", "1k")) + if (count == "int") { + message("* Rounding counts to the nearest integer.") + options(surveytable.tx_count = ".tx_count_int" + , surveytable.names_count = c("n", "Number", "SE", "LL", "UL")) + } else if (count == "1k") { + message("* Rounding counts to the nearest thousand.") + options(surveytable.tx_count = ".tx_count_1k" + , surveytable.names_count = c("n", "Number (000)", "SE (000)", "LL (000)", "UL (000)")) + } + } + + if (!is.null(lpe)) { + assert_that(is.flag(lpe), lpe %in% c(TRUE, FALSE)) + if (lpe) { + message("* Identifying low-precision estimates.") + } else { + message("* Not identifying low-precision estimates.") + } + options(surveytable.find_lpe = lpe) + } + + if (!is.null(drop_na)) { + assert_that(is.flag(drop_na), drop_na %in% c(TRUE, FALSE)) + if (drop_na) { + message("* Dropping missing values. Showing knowns only.") + } else { + message("* Retaining missing values.") + } + options(surveytable.drop_na = drop_na) + } + + if (!is.null(max_levels)) { + assert_that(is.count(max_levels)) + message(paste0("* Setting maximum number of levels to: ", max_levels)) + options(surveytable.max_levels = max_levels) + } + + if (!is.null(csv)) { + assert_that(is.string(csv) + , msg = "CSV file name must be a character string.") + if (nzchar(csv)) { + message(paste0("* Sending CSV output to: ", csv)) + if (file.exists(csv)) { + message("* (File already exists. Output will be appended to the end of the file.)") + } + message("* To turn off CSV output: set_opts(csv = '')") + } else { + message("* Turning off CSV output.") + } + options(surveytable.csv = csv) + } + + invisible(NULL) +} + +#' @rdname set_opts +#' @export +show_opts = function() { + + tx_count = getOption("surveytable.tx_count") + assert_that(is.string(tx_count), nzchar(tx_count)) + switch(tx_count + , ".tx_count_int" = "* Rounding counts to the nearest integer." + , ".tx_count_1k" = "* Rounding counts to the nearest thousand." + , ".tx_count_none" = "* Not rounding counts." + , " * Count rounding function: " %>% paste0(tx_count) + ) %>% message + + lpe = getOption("surveytable.find_lpe") + assert_that(is.flag(lpe), lpe %in% c(TRUE, FALSE)) + if (lpe) { + message("* Identifying low-precision estimates.") + } else { + message("* Not identifying low-precision estimates.") + } + + xx = getOption("surveytable.adjust_svyciprop") + assert_that(is.flag(xx), xx %in% c(TRUE, FALSE)) + if (xx) { + message("* Using adjusted Korn-Graubard CI's.") + } else { + message("* Using standard Korn-Graubard CI's.") + } + + drop_na = getOption("surveytable.drop_na") + assert_that(is.flag(drop_na), drop_na %in% c(TRUE, FALSE)) + if (drop_na) { + message("* Dropping missing values. Showing knowns only.") + } else { + message("* Retaining missing values.") + } + + max_levels = getOption("surveytable.max_levels") + assert_that(is.count(max_levels)) + message(paste0("* Maximum number of levels is: ", max_levels)) + + csv = getOption("surveytable.csv") + assert_that(is.string(csv) + , msg = "CSV file name must be a character string.") + if (nzchar(csv)) { + message(paste0("* Sending CSV output to: ", csv)) + if (file.exists(csv)) { + message("* (File already exists. Output will be appended to the end of the file.)") + } + message("* To turn off CSV output: set_opts(csv = '')") + } else { + message("* CSV output has been turned off.") + } + + invisible(NULL) +} diff --git a/R/set_output.R b/R/set_output.R deleted file mode 100644 index 5773b4a..0000000 --- a/R/set_output.R +++ /dev/null @@ -1,86 +0,0 @@ -#' Set output defaults -#' -#' `show_output()` shows the current defaults. -#' -#' @param drop_na drop missing values (`NA`)? Categorical variables only. -#' @param max_levels a categorical variable can have at most this many levels. Used to avoid printing huge tables. -#' @param csv name of a CSV file or "" to turn off CSV output -#' -#' @return (Nothing.) -#' @family options -#' @export -#' -#' @examples -#' tmp_file = tempfile(fileext = ".csv") -#' suppressMessages( set_output(csv = tmp_file) ) -#' tab("AGER") -#' set_output(csv = "") # Turn off CSV output -set_output = function(drop_na = NULL, max_levels = NULL, csv = NULL) { - # If making changes, update .onLoad() - - if (!is.null(drop_na)) { - assert_that(is.flag(drop_na), drop_na %in% c(TRUE, FALSE)) - if (drop_na) { - message("* Dropping missing values. Showing knowns only.") - } else { - message("* Retaining missing values.") - } - options(surveytable.drop_na = drop_na) - } - - if (!is.null(max_levels)) { - assert_that(is.count(max_levels)) - message(paste0("* Setting maximum number of levels to: ", max_levels)) - options(surveytable.max_levels = max_levels) - } - - if (!is.null(csv)) { - assert_that(is.string(csv) - , msg = "CSV file name must be a character string.") - if (nzchar(csv)) { - message(paste0("* Sending CSV output to: ", csv)) - if (file.exists(csv)) { - message("* (File already exists. Output will be appended to the end of the file.)") - } - message("* To turn off CSV output: set_output(csv = '')") - } else { - message("* Turning off CSV output.") - } - options(surveytable.csv = csv) - } - - message("* ?set_output for other options.") - invisible(NULL) -} - -#' @rdname set_output -#' @export -show_output = function() { - - drop_na = getOption("surveytable.drop_na") - assert_that(is.flag(drop_na), drop_na %in% c(TRUE, FALSE)) - if (drop_na) { - message("* Dropping missing values. Showing knowns only.") - } else { - message("* Retaining missing values.") - } - - max_levels = getOption("surveytable.max_levels") - assert_that(is.count(max_levels)) - message(paste0("* Maximum number of levels is: ", max_levels)) - - csv = getOption("surveytable.csv") - assert_that(is.string(csv) - , msg = "CSV file name must be a character string.") - if (nzchar(csv)) { - message(paste0("* Sending CSV output to: ", csv)) - if (file.exists(csv)) { - message("* (File already exists. Output will be appended to the end of the file.)") - } - message("* To turn off CSV output: set_output(csv = '')") - } else { - message("* CSV output has been turned off.") - } - - invisible(NULL) -} diff --git a/R/set_survey.R b/R/set_survey.R index 04590ba..f03dd9e 100644 --- a/R/set_survey.R +++ b/R/set_survey.R @@ -8,39 +8,25 @@ #' long name of the survey. Optionally, each variable in the survey can have an #' attribute called `label`, which is the variable's long name. #' -#' If you are not sure what the `mode` should be, leave it as `"default"`. Here is -#' what `mode` does: -#' -#' * `"general"` or `"default"`: -#' * Round counts to the nearest integer -- see [set_count_int()]. -#' * Do not look for low-precision estimates. -#' * Percentage CI's: use standard Korn-Graubard CI's. -#' -#' * `"nchs"`: -#' * Round counts to the nearest 1,000 -- see [set_count_1k()]. -#' * Identify low-precision estimates. -#' * Percentage CI's: adjust Korn-Graubard CI's for the number of degrees of freedom, matching the SUDAAN calculation. -#' #' @param design either a survey object (created with [survey::svydesign()] or #' [survey::svrepdesign()]); or, for an unweighted survey, a `data.frame`. -#' @param mode set certain options. See below. #' @param csv name of a CSV file +#' @param ... arguments to [set_opts()]. #' #' @family options -#' @return `set_survey`: info about the survey. `set_mode`: nothing. -#' @order 1 +#' @return info about the survey #' @export #' #' @examples #' set_survey(namcs2019sv) -#' set_mode("general") -set_survey = function(design, mode = "default", csv = getOption("surveytable.csv")) { +#' set_survey(namcs2019sv, mode = "general") +set_survey = function(design, csv = getOption("surveytable.csv"), ...) { # In case there's an error below and we don't set a new survey, # don't retain the previous survey either. env$survey = NULL options(surveytable.survey_label = "") - set_mode(mode = mode) + set_opts(...) if (is.string(design)) { label_default = design @@ -109,7 +95,6 @@ set_survey = function(design, mode = "default", csv = getOption("surveytable.csv .write_out(out, csv = csv) } - .load_survey = function() { design = env$survey assert_that(!is.null(design) diff --git a/R/surveytable.R b/R/surveytable.R index ffd7858..5dec9a7 100644 --- a/R/surveytable.R +++ b/R/surveytable.R @@ -20,8 +20,8 @@ NULL #' ## Low-precision estimates. #' #' Optionally, all of the tabulation functions can identify low-precision estimates. -#' To turn on this functionality, either set the `surveytable.find_lpe` option to `TRUE`, -#' or call [set_survey()] or [set_mode()] with the argument `mode = "NCHS"`. +#' Turn on this functionality using any of the following: [set_opts](lpe = TRUE), +#' [set_opts](mode = "nchs"), [set_survey](*, mode = "nchs"), or `options(surveytable.find_lpe = TRUE)`. #' #' By default, low-precision estimates are identified using National Center for #' Health Statistics (NCHS) algorithms. However, this can be changed, as described @@ -31,8 +31,8 @@ NULL #' estimates. #' #' * `surveytable.find_lpe`: should the tabulation functions look for low-precision -#' estimates? You can change this directly with `options()` or with the `mode` argument -#' to [set_survey()] or [set_mode()]. +#' estimates? You can change this directly with `options()` or with either [set_opts()] +#' or [set_survey()]. #' * `surveytable.lpe_n`, `surveytable.lpe_counts`, `surveytable.lpe_percents`: names #' of 3 functions. #' diff --git a/R/svyciprop_adjusted.R b/R/svyciprop_adjusted.R index cf91542..3235c4e 100644 --- a/R/svyciprop_adjusted.R +++ b/R/svyciprop_adjusted.R @@ -7,7 +7,7 @@ #' #' `df_method`: for `"default"`, `df = degf(design)`; for `"NHIS"`, `df = nrow(design) - 1`. #' -#' To use this function in tabulations, call [set_survey()] or [set_mode()] with the +#' To use this function in tabulations, call [set_survey()] or [set_opts()] with the #' `mode = "NCHS"` argument, or type: `options(surveytable.adjust_svyciprop = TRUE)`. #' #' @param formula see `survey::svyciprop()`. @@ -22,9 +22,9 @@ #' #' @examples #' set_survey(namcs2019sv) -#' set_mode("NCHS") +#' set_opts(mode = "NCHS") #' tab("AGER") -#' set_mode("general") +#' set_opts(mode = "general") svyciprop_adjusted = function(formula , design , method = c("logit", "likelihood", "asin", "beta" diff --git a/R/tab.R b/R/tab.R index 5440bfb..707c770 100644 --- a/R/tab.R +++ b/R/tab.R @@ -141,7 +141,7 @@ tab = function(... , ": categorical variable with too many levels: " , nlv, ", but ", max_levels , " allowed. Try increasing the max_levels argument or " - , "see ?set_output" + , "see ?set_opts" ) return(invisible(NULL)) } diff --git a/R/z_utils.R b/R/z_utils.R index eac8c6b..fd9b514 100644 --- a/R/z_utils.R +++ b/R/z_utils.R @@ -21,3 +21,11 @@ assert_that(noNA(xx), noNA(levels(xx))) xx } + +.mymatch = function(arg, table) { + assert_that(is.string(arg), nzchar(arg)) + table %<>% tolower + idx = arg %>% tolower %>% pmatch(table) + assert_that(noNA(idx), msg = paste("Unknown value:", arg)) + table[idx] +} diff --git a/R/zzz.R b/R/zzz.R index bd9db99..391c49d 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -23,34 +23,35 @@ env = new.env() options( surveytable.survey_label = "" - , surveytable.find_lpe = TRUE + ## set_opts(mode = "general") + , surveytable.tx_count = ".tx_count_int" + , surveytable.names_count = c("n", "Number", "SE", "LL", "UL") + , surveytable.find_lpe = FALSE + , surveytable.adjust_svyciprop = FALSE + + ## related , surveytable.lpe_n = ".lpe_n" , surveytable.lpe_counts = ".lpe_counts" , surveytable.lpe_percents = ".lpe_percents" + , surveytable.adjust_svyciprop.df_method = "NHIS" - , surveytable.tx_count = ".tx_count_1k" - , surveytable.names_count = c("n", "Number (000)", "SE (000)", "LL (000)", "UL (000)") + ## other set_opts() + , surveytable.drop_na = FALSE + , surveytable.max_levels = 20 + , surveytable.csv = "" + ## other , surveytable.tx_prct = ".tx_prct" , surveytable.names_prct = c("Percent", "SE", "LL", "UL") - , surveytable.csv = "" - , surveytable.max_levels = 20 - , surveytable.drop_na = FALSE - , surveytable.rate_per = 100 , surveytable.tx_rate = ".tx_rate" , surveytable.tx_numeric = ".tx_numeric" - , surveytable.adjust_svyciprop = FALSE - , surveytable.adjust_svyciprop.df_method = "NHIS" - , surveytable.svychisq_statistic = "F" , surveytable.p.adjust_method = "bonferroni" ) - # No - creates a startup message which cannot be suppressed. - # set_count_1k() } .tx_prct = function(x) { @@ -64,3 +65,25 @@ env = new.env() .tx_numeric = function(x) { signif(x, 3) } + +.tx_count_1k = function(x) { + ## Huge UL -> Inf + x$rat = x$ul / x$x + idx = which(x$rat > 4e3) + x$ul[idx] = Inf + x$rat = NULL + + round(x / 1e3) +} +.tx_count_int = function(x) { + ## Huge UL -> Inf + x$rat = x$ul / x$x + idx = which(x$rat > 4e3) + x$ul[idx] = Inf + x$rat = NULL + + round(x) +} +.tx_count_none = function(x) { + x +} diff --git a/README.md b/README.md index 996beb0..69ae026 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,6 @@ library(surveytable) ``` r set_survey(namcs2019sv) -#> * Mode: General. ``` diff --git a/_pkgdown.yml b/_pkgdown.yml index 145f452..7b8f103 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -5,7 +5,6 @@ reference: - title: "Begin" contents: - set_survey - - set_count_1k - var_list - title: "Counts, percentages, and means" contents: @@ -34,7 +33,7 @@ reference: - rccsu2018 - title: "Other" contents: - - set_output + - set_opts - show_options - surveytable-options - codebook diff --git a/docs/articles/Advanced-topics.html b/docs/articles/Advanced-topics.html index 2a953df..52c5b81 100644 --- a/docs/articles/Advanced-topics.html +++ b/docs/articles/Advanced-topics.html @@ -266,8 +266,7 @@

Subsetting a survey
 newsurvey = survey_subset(namcs2019sv, NUMMED > 0
   , label = "NAMCS 2019 PUF: NUMMED 1+")
-set_survey(newsurvey)
-## * Mode: General.
+set_survey(newsurvey)

Survey info {NAMCS 2019 PUF: NUMMED 1+} diff --git a/docs/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html b/docs/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html index ebf73ce..379aa1e 100644 --- a/docs/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html +++ b/docs/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html @@ -108,8 +108,7 @@

Begin library(surveytable)

Now, specify the survey that you’d like to analyze.

-set_survey(namcs2019sv)
-## * Mode: General.
+set_survey(namcs2019sv)
Survey info {NAMCS 2019 PUF} @@ -149,7 +148,7 @@

Begin about identifying low-precision estimates, you can skip this command. To turn on the NCHS-specific options:

-set_mode("NCHS")
+set_opts(mode = "NCHS")
 ## * Mode: NCHS.
@@ -7466,10 +7465,9 @@

More advanced coding
-tmp_file = tempfile(fileext = ".csv")
-suppressMessages( set_output(csv = tmp_file) )
-
-for (vr in c("AGER", "Age group", "SEX", "Age x Sex")) {
+set_opts(csv = "output.csv")

+
+for (vr in c("AGER", "Age group", "SEX", "Age x Sex")) {
     var_cross("tmp", "MAJOR", vr)
     for (lvl in levels(surveytable:::env$survey$variables[,vr])) {
         tab_subset("SPECCAT", "tmp", paste0("Preventive care: ", lvl))
@@ -7481,9 +7479,8 @@ 

More advanced coding## already exists. ## Warning in var_cross("tmp", "MAJOR", vr): tmp: overwriting a variable that ## already exists. -set_output(csv = "") -## * Turning off CSV output. -## * ?set_output for other options.

+set_opts(csv = "") +## * Turning off CSV output.
  • Since tab_subset() is called from within a for loop, if we wanted to print to the screen, we would @@ -7509,7 +7506,7 @@

    More advanced coding
    +
     vr = "AGER"
     var_cross("tmp", "MAJOR", vr)
     ## Warning in var_cross("tmp", "MAJOR", vr): tmp: overwriting a variable that
    diff --git a/docs/articles/Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report.html b/docs/articles/Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report.html
    index fc7517d..bd9b70e 100644
    --- a/docs/articles/Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report.html
    +++ b/docs/articles/Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report.html
    @@ -108,8 +108,7 @@ 

    Begin library(surveytable)

    Now, specify the survey that you’d like to analyze.

    -set_survey(rccsu2018)
    -## * Mode: General.
    +set_survey(rccsu2018)
    Survey info {RCC SU 2018 PUF} @@ -149,7 +148,7 @@

    Begin about identifying low-precision estimates, you can skip this command. To turn on the NCHS-specific options:

    -set_mode("NCHS")
    +set_opts(mode = "NCHS")
     ## * Mode: NCHS.

    Alternatively, you can combine these two commands into a single command, like so:

    diff --git a/docs/articles/surveytable.html b/docs/articles/surveytable.html index 725d6ce..51ddec0 100644 --- a/docs/articles/surveytable.html +++ b/docs/articles/surveytable.html @@ -250,8 +250,7 @@

    Begin analysis

    First, specify the survey object that you’d like to analyze.

    -set_survey(namcs2019sv)
    -#> * Mode: General.
    +set_survey(namcs2019sv)
    Survey info {NAMCS 2019 PUF} @@ -291,7 +290,7 @@

    Begin analysis
    -set_mode("NCHS")
    +set_opts(mode = "NCHS")
     #> * Mode: NCHS.

    List variables @@ -618,17 +617,21 @@

    Tabulate categorical and log
  • the estimated percentage, its standard error, and its 95% confidence interval.
  • -

    NCHS presentation standards. The tab() -function also applies the National Center for Health Statistics (NCHS) -presentation standards for counts and percentages, and flags estimates -if, according to the standards, they should be suppressed, footnoted, or -reviewed by an analyst. The CIs that are displayed are the ones that are -used by the NCHS presentation standards. Specifically, for counts, the -tables show the log Student’s t 95% CI, with adaptations for complex -surveys; for percentages, they show the 95% Korn and Graubard CI.

    -

    One does not need to do anything extra to perform presentation -standards checking – it is performed automatically. For example, let’s -tabulate PAYNOCHG:

    +

    Low-precision estimates. Optionally, the +tab() function, as well as the other tabulation functions +that are discussed below, can automatically identify low-precision +estimates using algorithms developed at NCHS. For counts, rates, and +percentages, the functions flag estimates if, according to the +algorithms, they should not be presented, should be reviewed by a +clearance official, or should be presented with a footnote. If no +estimates are flagged by the checks, the table has a footnote that +indicates this. If the checks do identify an estimate, that is denoted +in an additional column and in the table footnote.

    +

    Turn on this functionality using any of the following: +set_opts(lpe = TRUE), set_opts(mode = "nchs"), +set_survey(*, mode = "nchs"), or +options(surveytable.find_lpe = TRUE).

    +

    As an example, let’s tabulate PAYNOCHG:

     tab("PAYNOCHG")
    @@ -757,11 +760,14 @@

    Tabulate categorical and log

    -

    This table tells us that, according to the NCHS presentation -standards, the estimated number of visits in which there was no charge -for the visit should be suppressed due to low precision. However, the -lack of a percentage flag indicates that the estimated percentage of -such visits can be shown.

    +

    This table tells us that the estimated number of visits in which +there was no charge for the visit has low precision. Intuitively, we can +see that the CI for this count estimate is very wide, indicating high +uncertainty.

    +

    The CIs that are displayed are the ones that are used by the NCHS +presentation standards. Specifically, for counts, the tables show the +log Student’s t 95% CI, with adaptations for complex surveys; for +percentages, they show the 95% Korn and Graubard CI.

    Drop missing values. Some variables might contain missing values (NA). Consider the following variable, which is not part of the actual survey, but was constructed specifically for @@ -8442,13 +8448,13 @@

    Save the outputcsv that specifies the name of a comma-separated values (CSV) file to save the output to. Alternatively, you can name the default CSV output file using the -set_output() function. For example, the following directs +set_opts() function. For example, the following directs surveytable to send all future output to a CSV file, create some tables, and then turn off sending output to the file:

    -set_output(csv = "output.csv")
    +set_opts(csv = "output.csv")

    -tab("MDDO", "SPECCAT", "MSA")
    +tab("MDDO")
    Type of doctor (MD or DO) {NAMCS 2019 PUF} @@ -8565,275 +8571,9 @@

    Save the output

    - - ----------- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -Type of specialty (Primary, Medical, Surgical) {NAMCS 2019 PUF} -
    -Level - -n - -Number (000) - -SE (000) - -LL (000) - -UL (000) - -Percent - -SE - -LL - -UL -
    -Primary care specialty - -2,993 - -521,466 - -31,136 - -463,840 - -586,252 - -50.3 - -2.6 - -45.1 - -55.5 -
    -Surgical care specialty - -3,050 - -214,832 - -31,110 - -161,661 - -285,490 - -20.7 - -3   - -15.1 - -27.3 -
    -Medical care specialty - -2,207 - -300,186 - -43,497 - -225,806 - -399,067 - -29   - -3.6 - -22.1 - -36.6 -
    -N = 8250. Checked NCHS presentation standards. Nothing to report. -
    - - ----------- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -Metropolitan Statistical Area Status of physician location {NAMCS 2019 -PUF} -
    -Level - -n - -Number (000) - -SE (000) - -LL (000) - -UL (000) - -Percent - -SE - -LL - -UL -
    -MSA (Metropolitan Statistical Area) - -7,496 - -973,676 - -50,515 - -879,490 - -1,077,947 - -93.9 - -1.7 - -89.7 - -96.8 -
    -Non-MSA - -754 - -62,809 - -17,549 - -36,249 - -108,830 - -6.1 - -1.7 - -3.2 - -10.3 -
    -N = 8250. Checked NCHS presentation standards. Nothing to report. -
    -set_output(csv = "")
    -#> * Turning off CSV output.
    -#> * ?set_output for other options.
    +set_opts(csv = "") +#> * Turning off CSV output.

    If the tabulation functions are called from within an R Markdown notebook or a Quarto document, they produce HTML or LaTeX tables, as appropriate. This makes it easy to incorporate the output of the diff --git a/docs/index.html b/docs/index.html index fb910f5..3559c4d 100644 --- a/docs/index.html +++ b/docs/index.html @@ -130,8 +130,7 @@

    ExampleSpecify the survey that you wish you analyze. surveytable comes with a survey called namcs2019sv, for use in examples.
    -set_survey(namcs2019sv)
    -#> * Mode: General.
    +set_survey(namcs2019sv)
    Survey info {NAMCS 2019 PUF} diff --git a/docs/news/index.html b/docs/news/index.html index bf2a616..672f234 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -59,8 +59,9 @@

    surveytable (development version)

    -
    • rccsu2018
    • -
    • set_mode()
    • +
      • Another public use data file for use in examples: rccsu2018.
      • +
      • +set_opts() replaces several other functions for setting options.

    surveytable 0.9.4

    CRAN release: 2024-05-20

    diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index a79b67e..b3b2e37 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -6,7 +6,7 @@ articles: Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables: Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report: Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report.html surveytable: surveytable.html -last_built: 2024-09-05T21:12Z +last_built: 2024-09-16T19:08Z urls: reference: https://cdcgov.github.io/surveytable/reference article: https://cdcgov.github.io/surveytable/articles diff --git a/docs/reference/codebook.html b/docs/reference/codebook.html index be3883d..e05561a 100644 --- a/docs/reference/codebook.html +++ b/docs/reference/codebook.html @@ -87,7 +87,6 @@

    Value

    Examples

    set_survey(namcs2019sv)
    -#> * Mode: General.
     #>                         Survey info {NAMCS 2019 PUF}                         
     #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
     #> │ Variables │ Observations │ Design                                         │
    @@ -101,7 +100,6 @@ 

    Examples#> └───────────┴──────────────┴────────────────────────────────────────────────┘ #> codebook() -#> * Mode: General. #> Survey info {NAMCS 2019 PUF} #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐ #> │ Variables │ Observations │ Design │ diff --git a/docs/reference/deprecated.html b/docs/reference/deprecated.html new file mode 100644 index 0000000..c70f3f9 --- /dev/null +++ b/docs/reference/deprecated.html @@ -0,0 +1,101 @@ + +Deprecated functions — deprecated • surveytable + Skip to contents + + +
    +
    +
    + +
    +

    [Deprecated]

    +
    + +
    +

    Usage

    +
    set_mode(mode = "general")
    +
    +set_count_1k()
    +
    +set_count_int()
    +
    +set_output(drop_na = NULL, max_levels = NULL, csv = NULL)
    +
    + +
    +

    Details

    +

    Use set_opts() instead of any of the following: set_mode(), set_count_1k(), +set_count_int(), set_output().

    +
    + +
    + + +
    + + + +
    + + + + + + + diff --git a/docs/reference/figures/lifecycle-archived.svg b/docs/reference/figures/lifecycle-archived.svg new file mode 100644 index 0000000..745ab0c --- /dev/null +++ b/docs/reference/figures/lifecycle-archived.svg @@ -0,0 +1,21 @@ + + lifecycle: archived + + + + + + + + + + + + + + + lifecycle + + archived + + diff --git a/docs/reference/figures/lifecycle-defunct.svg b/docs/reference/figures/lifecycle-defunct.svg new file mode 100644 index 0000000..d5c9559 --- /dev/null +++ b/docs/reference/figures/lifecycle-defunct.svg @@ -0,0 +1,21 @@ + + lifecycle: defunct + + + + + + + + + + + + + + + lifecycle + + defunct + + diff --git a/docs/reference/figures/lifecycle-deprecated.svg b/docs/reference/figures/lifecycle-deprecated.svg new file mode 100644 index 0000000..b61c57c --- /dev/null +++ b/docs/reference/figures/lifecycle-deprecated.svg @@ -0,0 +1,21 @@ + + lifecycle: deprecated + + + + + + + + + + + + + + + lifecycle + + deprecated + + diff --git a/docs/reference/figures/lifecycle-experimental.svg b/docs/reference/figures/lifecycle-experimental.svg new file mode 100644 index 0000000..5d88fc2 --- /dev/null +++ b/docs/reference/figures/lifecycle-experimental.svg @@ -0,0 +1,21 @@ + + lifecycle: experimental + + + + + + + + + + + + + + + lifecycle + + experimental + + diff --git a/docs/reference/figures/lifecycle-maturing.svg b/docs/reference/figures/lifecycle-maturing.svg new file mode 100644 index 0000000..897370e --- /dev/null +++ b/docs/reference/figures/lifecycle-maturing.svg @@ -0,0 +1,21 @@ + + lifecycle: maturing + + + + + + + + + + + + + + + lifecycle + + maturing + + diff --git a/docs/reference/figures/lifecycle-questioning.svg b/docs/reference/figures/lifecycle-questioning.svg new file mode 100644 index 0000000..7c1721d --- /dev/null +++ b/docs/reference/figures/lifecycle-questioning.svg @@ -0,0 +1,21 @@ + + lifecycle: questioning + + + + + + + + + + + + + + + lifecycle + + questioning + + diff --git a/docs/reference/figures/lifecycle-soft-deprecated.svg b/docs/reference/figures/lifecycle-soft-deprecated.svg new file mode 100644 index 0000000..9c166ff --- /dev/null +++ b/docs/reference/figures/lifecycle-soft-deprecated.svg @@ -0,0 +1,21 @@ + + lifecycle: soft-deprecated + + + + + + + + + + + + + + + lifecycle + + soft-deprecated + + diff --git a/docs/reference/figures/lifecycle-stable.svg b/docs/reference/figures/lifecycle-stable.svg new file mode 100644 index 0000000..9bf21e7 --- /dev/null +++ b/docs/reference/figures/lifecycle-stable.svg @@ -0,0 +1,29 @@ + + lifecycle: stable + + + + + + + + + + + + + + + + lifecycle + + + + stable + + + diff --git a/docs/reference/figures/lifecycle-superseded.svg b/docs/reference/figures/lifecycle-superseded.svg new file mode 100644 index 0000000..db8d757 --- /dev/null +++ b/docs/reference/figures/lifecycle-superseded.svg @@ -0,0 +1,21 @@ + + lifecycle: superseded + + + + + + + + + + + + + + + lifecycle + + superseded + + diff --git a/docs/reference/index.html b/docs/reference/index.html index 6b93579..baa11e5 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -69,16 +69,11 @@

    Begin

    - set_survey() set_mode() + set_survey()
    Specify the survey to analyze
    - set_count_1k() set_count_int() -
    -
    Rounding counts
    -
    - var_list()
    List variables in a survey.
    @@ -224,9 +219,9 @@

    Other

    - set_output() show_output() + set_opts() show_opts()
    -
    Set output defaults
    +
    Set certain options
    show_options() diff --git a/docs/reference/print.surveytable_table.html b/docs/reference/print.surveytable_table.html index 584d660..70daa68 100644 --- a/docs/reference/print.surveytable_table.html +++ b/docs/reference/print.surveytable_table.html @@ -95,7 +95,6 @@

    Value

    Examples

    set_survey(namcs2019sv)
    -#> * Mode: General.
     #>                         Survey info {NAMCS 2019 PUF}                         
     #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
     #> │ Variables │ Observations │ Design                                         │
    diff --git a/docs/reference/set_count_1k.html b/docs/reference/set_count_1k.html
    deleted file mode 100644
    index d433788..0000000
    --- a/docs/reference/set_count_1k.html
    +++ /dev/null
    @@ -1,155 +0,0 @@
    -
    -Rounding counts — set_count_1k • surveytable
    -    Skip to contents
    -    
    -
    -    
    -
    -
    - -
    -

    Determines how counts should be rounded.

    -
    - -
    -

    Usage

    -
    set_count_1k()
    -
    -set_count_int()
    -
    - -
    -

    Value

    - - -

    (Nothing.)

    -
    -
    -

    Details

    - -
    • set_count_1k(): round counts to the nearest 1,000.

    • -
    • set_count_int(): round counts to the nearest integer.

    • -
    -
    -

    See also

    - -
    - -
    -

    Examples

    -
    set_survey(namcs2019sv)
    -#> * Mode: General.
    -#>                         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)                       │
    -#> └───────────┴──────────────┴────────────────────────────────────────────────┘
    -#> 
    -set_count_int()
    -#> * Rounding counts to the nearest integer.
    -#> * ?set_count_int for other options.
    -total()
    -#>                        Total {NAMCS 2019 PUF}                       
    -#> ┌───────┬───────────────┬────────────┬─────────────┬───────────────┐
    -#> │     n │        Number │         SE │          LL │            UL │
    -#> ├───────┼───────────────┼────────────┼─────────────┼───────────────┤
    -#> │ 8,250 │ 1,036,484,356 │ 48,836,217 │ 945,013,590 │ 1,136,808,860 │
    -#> └───────┴───────────────┴────────────┴─────────────┴───────────────┘
    -#>   N = 8250.                                                         
    -#> 
    -
    -set_count_1k()
    -#> * Rounding counts to the nearest 1,000.
    -#> * ?set_count_1k for other options.
    -total()
    -#>                   Total {NAMCS 2019 PUF}                  
    -#> ┌───────┬──────────────┬──────────┬──────────┬───────────┐
    -#> │     n │ Number (000) │ SE (000) │ LL (000) │  UL (000) │
    -#> ├───────┼──────────────┼──────────┼──────────┼───────────┤
    -#> │ 8,250 │    1,036,484 │   48,836 │  945,014 │ 1,136,809 │
    -#> └───────┴──────────────┴──────────┴──────────┴───────────┘
    -#>   N = 8250.                                               
    -#> 
    -
    -
    -
    - - -
    - - - -
    - - - - - - - diff --git a/docs/reference/set_opts.html b/docs/reference/set_opts.html new file mode 100644 index 0000000..8980de8 --- /dev/null +++ b/docs/reference/set_opts.html @@ -0,0 +1,208 @@ + +Set certain options — set_opts • surveytable + Skip to contents + + +
    +
    +
    + +
    +

    set_opts() sets certain options. show_opts() shows the options that have +been set. More advanced users can also use options() and show_options() for +more detailed control.

    +
    + +
    +

    Usage

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

    + +
    +
    +

    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.

      • +
    • +
    • "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.

      • +
    • +
    +
    +

    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()
    +#> * 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.
    +
    +
    +
    + + +
    + + + +
    + + + + + + + diff --git a/docs/reference/set_output.html b/docs/reference/set_output.html deleted file mode 100644 index 5190bfa..0000000 --- a/docs/reference/set_output.html +++ /dev/null @@ -1,151 +0,0 @@ - -Set output defaults — set_output • surveytable - Skip to contents - - -
    -
    -
    - -
    -

    show_output() shows the current defaults.

    -
    - -
    -

    Usage

    -
    set_output(drop_na = NULL, max_levels = NULL, csv = NULL)
    -
    -show_output()
    -
    - -
    -

    Arguments

    -
    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.)

    -
    -
    -

    See also

    - -
    - -
    -

    Examples

    -
    tmp_file = tempfile(fileext = ".csv")
    -suppressMessages( set_output(csv = tmp_file) )
    -tab("AGER")
    -#>                                 Patient age recode {NAMCS 2019 PUF}                                 
    -#> ┌─────────────┬───────┬─────────────┬──────────┬──────────┬──────────┬─────────┬─────┬──────┬──────┐
    -#> │ Level       │     n │      Number │ SE (000) │ LL (000) │ UL (000) │ Percent │  SE │   LL │   UL │
    -#> │             │       │       (000) │          │          │          │         │     │      │      │
    -#> ├─────────────┼───────┼─────────────┼──────────┼──────────┼──────────┼─────────┼─────┼──────┼──────┤
    -#> │ 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_output(csv = "") # Turn off CSV output
    -#> * Turning off CSV output.
    -#> * ?set_output for other options.
    -
    -
    -
    - - -
    - - - -
    - - - - - - - diff --git a/docs/reference/set_survey.html b/docs/reference/set_survey.html index 94c41c6..4f19ce9 100644 --- a/docs/reference/set_survey.html +++ b/docs/reference/set_survey.html @@ -58,7 +58,7 @@
    @@ -70,9 +70,7 @@

    Usage

    -
    set_survey(design, mode = "default", csv = getOption("surveytable.csv"))
    -
    -set_mode(mode = "default")
    +
    set_survey(design, csv = getOption("surveytable.csv"), ...)
    @@ -82,40 +80,30 @@

    Argumentssurvey::svrepdesign()); or, for an unweighted survey, a data.frame.

    -
    mode
    -

    set certain options. See below.

    - -
    csv

    name of a CSV file

    + +
    ...
    +

    arguments to set_opts().

    +

    Value

    -

    set_survey: info about the survey. set_mode: nothing.

    +

    info about the survey

    Details

    Optionally, the survey can have an attribute called label, which is the long name of the survey. Optionally, each variable in the survey can have an attribute called label, which is the variable's long name.

    -

    If you are not sure what the mode should be, leave it as "default". Here is -what mode does:

    • "general" or "default":

      • Round counts to the nearest integer -- see set_count_int().

      • -
      • Do not look for low-precision estimates.

      • -
      • Percentage CI's: use standard Korn-Graubard CI's.

      • -
    • -
    • "nchs":

      • Round counts to the nearest 1,000 -- see set_count_1k().

      • -
      • Identify low-precision estimates.

      • -
      • Percentage CI's: adjust Korn-Graubard CI's for the number of degrees of freedom, matching the SUDAAN calculation.

      • -
    • -
    +

    See also

    @@ -123,7 +111,6 @@

    See also

    Examples

    set_survey(namcs2019sv)
    -#> * Mode: General.
     #>                         Survey info {NAMCS 2019 PUF}                         
     #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
     #> │ Variables │ Observations │ Design                                         │
    @@ -136,8 +123,20 @@ 

    Examples#> │ │ │ , data = namcs2019sv_df) │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #> -set_mode("general") +set_survey(namcs2019sv, mode = "general") #> * Mode: General. +#> 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) │ +#> └───────────┴──────────────┴────────────────────────────────────────────────┘ +#>

    children = survey_subset(namcs2019sv, AGE < 18, "Children < 18")
     set_survey(children)
    -#> * Mode: General.
     #>                          Survey info {Children < 18}                         
     #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
     #> │ Variables │ Observations │ Design                                         │
    diff --git a/docs/reference/surveytable-options.html b/docs/reference/surveytable-options.html
    index fc20309..c066274 100644
    --- a/docs/reference/surveytable-options.html
    +++ b/docs/reference/surveytable-options.html
    @@ -74,15 +74,15 @@ 

    Low-precision estimates.Optionally, all of the tabulation functions can identify low-precision estimates. -To turn on this functionality, either set the surveytable.find_lpe option to TRUE, -or call set_survey() or set_mode() with the argument mode = "NCHS".

    +Turn on this functionality using any of the following: set_opts(lpe = TRUE), +set_opts(mode = "nchs"), set_survey(*, mode = "nchs"), or options(surveytable.find_lpe = TRUE).

    By default, low-precision estimates are identified using National Center for Health Statistics (NCHS) algorithms. However, this can be changed, as described below.

    Here is a description of the options related to the identification of low-precision estimates.

    • surveytable.find_lpe: should the tabulation functions look for low-precision -estimates? You can change this directly with options() or with the mode argument -to set_survey() or set_mode().

    • +estimates? You can change this directly with options() or with either set_opts() +or set_survey().

    • surveytable.lpe_n, surveytable.lpe_counts, surveytable.lpe_percents: names of 3 functions.

    The argument for surveytable.lpe_n is a vector of the number of observations @@ -118,8 +118,7 @@

    See also

    Useful links:

    Other options: -set_count_1k(), -set_output(), +set_opts(), set_survey(), show_options()

    diff --git a/docs/reference/svyciprop_adjusted.html b/docs/reference/svyciprop_adjusted.html index 2d18dd8..335c77c 100644 --- a/docs/reference/svyciprop_adjusted.html +++ b/docs/reference/svyciprop_adjusted.html @@ -113,14 +113,13 @@

    Value

    Details

    Written by Makram Talih in 2019.

    df_method: for "default", df = degf(design); for "NHIS", df = nrow(design) - 1.

    -

    To use this function in tabulations, call set_survey() or set_mode() with the +

    To use this function in tabulations, call set_survey() or set_opts() with the mode = "NCHS" argument, or type: options(surveytable.adjust_svyciprop = TRUE).

    Examples

    set_survey(namcs2019sv)
    -#> * Mode: General.
     #>                         Survey info {NAMCS 2019 PUF}                         
     #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
     #> │ Variables │ Observations │ Design                                         │
    @@ -133,7 +132,7 @@ 

    Examples#> │ │ │ , data = namcs2019sv_df) │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #> -set_mode("NCHS") +set_opts(mode = "NCHS") #> * Mode: NCHS. tab("AGER") #> Patient age recode {NAMCS 2019 PUF} @@ -157,7 +156,7 @@

    Examples#> └─────────────┴───────┴─────────────┴──────────┴──────────┴──────────┴─────────┴─────┴──────┴──────┘ #> N = 8250. Checked NCHS presentation standards. Nothing to report. #> -set_mode("general") +set_opts(mode = "general") #> * Mode: General.

    diff --git a/docs/reference/tab.html b/docs/reference/tab.html index e2b0441..c7064c6 100644 --- a/docs/reference/tab.html +++ b/docs/reference/tab.html @@ -140,7 +140,6 @@

    See also

    Examples

    set_survey(namcs2019sv)
    -#> * Mode: General.
     #>                         Survey info {NAMCS 2019 PUF}                         
     #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
     #> │ Variables │ Observations │ Design                                         │
    diff --git a/docs/reference/tab_rate.html b/docs/reference/tab_rate.html
    index 577e62d..35586b9 100644
    --- a/docs/reference/tab_rate.html
    +++ b/docs/reference/tab_rate.html
    @@ -122,7 +122,6 @@ 

    See also

    Examples

    set_survey(namcs2019sv)
    -#> * Mode: General.
     #>                         Survey info {NAMCS 2019 PUF}                         
     #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
     #> │ Variables │ Observations │ Design                                         │
    diff --git a/docs/reference/tab_subset.html b/docs/reference/tab_subset.html
    index 594cfeb..6648692 100644
    --- a/docs/reference/tab_subset.html
    +++ b/docs/reference/tab_subset.html
    @@ -157,7 +157,6 @@ 

    See also

    Examples

    set_survey(namcs2019sv)
    -#> * Mode: General.
     #>                         Survey info {NAMCS 2019 PUF}                         
     #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
     #> │ Variables │ Observations │ Design                                         │
    diff --git a/docs/reference/tab_subset_rate.html b/docs/reference/tab_subset_rate.html
    index d4f823c..a59be6c 100644
    --- a/docs/reference/tab_subset_rate.html
    +++ b/docs/reference/tab_subset_rate.html
    @@ -134,7 +134,6 @@ 

    See also

    Examples

    set_survey(namcs2019sv)
    -#> * Mode: General.
     #>                         Survey info {NAMCS 2019 PUF}                         
     #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
     #> │ Variables │ Observations │ Design                                         │
    diff --git a/docs/reference/total.html b/docs/reference/total.html
    index d7f9dc4..f32f9c3 100644
    --- a/docs/reference/total.html
    +++ b/docs/reference/total.html
    @@ -92,7 +92,6 @@ 

    See also

    Examples

    set_survey(namcs2019sv)
    -#> * Mode: General.
     #>                         Survey info {NAMCS 2019 PUF}                         
     #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
     #> │ Variables │ Observations │ Design                                         │
    diff --git a/docs/reference/total_rate.html b/docs/reference/total_rate.html
    index 67de6c7..698e598 100644
    --- a/docs/reference/total_rate.html
    +++ b/docs/reference/total_rate.html
    @@ -104,7 +104,6 @@ 

    See also

    Examples

    set_survey(namcs2019sv)
    -#> * Mode: General.
     #>                         Survey info {NAMCS 2019 PUF}                         
     #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
     #> │ Variables │ Observations │ Design                                         │
    diff --git a/docs/reference/var_all.html b/docs/reference/var_all.html
    index 6f43282..9a5c576 100644
    --- a/docs/reference/var_all.html
    +++ b/docs/reference/var_all.html
    @@ -101,7 +101,6 @@ 

    See also

    Examples

    set_survey(namcs2019sv)
    -#> * Mode: General.
     #>                         Survey info {NAMCS 2019 PUF}                         
     #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
     #> │ Variables │ Observations │ Design                                         │
    diff --git a/docs/reference/var_any.html b/docs/reference/var_any.html
    index da15fc3..7e92a65 100644
    --- a/docs/reference/var_any.html
    +++ b/docs/reference/var_any.html
    @@ -101,7 +101,6 @@ 

    See also

    Examples

    set_survey(namcs2019sv)
    -#> * Mode: General.
     #>                         Survey info {NAMCS 2019 PUF}                         
     #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
     #> │ Variables │ Observations │ Design                                         │
    diff --git a/docs/reference/var_case.html b/docs/reference/var_case.html
    index 6597cdd..caca1f9 100644
    --- a/docs/reference/var_case.html
    +++ b/docs/reference/var_case.html
    @@ -106,7 +106,6 @@ 

    See also

    Examples

    set_survey(namcs2019sv)
    -#> * Mode: General.
     #>                         Survey info {NAMCS 2019 PUF}                         
     #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
     #> │ Variables │ Observations │ Design                                         │
    diff --git a/docs/reference/var_collapse.html b/docs/reference/var_collapse.html
    index b80f0f2..0c01605 100644
    --- a/docs/reference/var_collapse.html
    +++ b/docs/reference/var_collapse.html
    @@ -102,7 +102,6 @@ 

    See also

    Examples

    set_survey(namcs2019sv)
    -#> * Mode: General.
     #>                         Survey info {NAMCS 2019 PUF}                         
     #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
     #> │ Variables │ Observations │ Design                                         │
    diff --git a/docs/reference/var_copy.html b/docs/reference/var_copy.html
    index 1919ece..26bb9c8 100644
    --- a/docs/reference/var_copy.html
    +++ b/docs/reference/var_copy.html
    @@ -101,7 +101,6 @@ 

    See also

    Examples

    set_survey(namcs2019sv)
    -#> * Mode: General.
     #>                         Survey info {NAMCS 2019 PUF}                         
     #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
     #> │ Variables │ Observations │ Design                                         │
    diff --git a/docs/reference/var_cross.html b/docs/reference/var_cross.html
    index 0762532..3f5e17c 100644
    --- a/docs/reference/var_cross.html
    +++ b/docs/reference/var_cross.html
    @@ -105,7 +105,6 @@ 

    See also

    Examples

    set_survey(namcs2019sv)
    -#> * Mode: General.
     #>                         Survey info {NAMCS 2019 PUF}                         
     #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
     #> │ Variables │ Observations │ Design                                         │
    diff --git a/docs/reference/var_cut.html b/docs/reference/var_cut.html
    index a286070..4eff4da 100644
    --- a/docs/reference/var_cut.html
    +++ b/docs/reference/var_cut.html
    @@ -106,7 +106,6 @@ 

    See also

    Examples

    set_survey(namcs2019sv)
    -#> * Mode: General.
     #>                         Survey info {NAMCS 2019 PUF}                         
     #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
     #> │ Variables │ Observations │ Design                                         │
    diff --git a/docs/reference/var_list.html b/docs/reference/var_list.html
    index 22f279e..39af02d 100644
    --- a/docs/reference/var_list.html
    +++ b/docs/reference/var_list.html
    @@ -91,7 +91,6 @@ 

    Value

    Examples

    set_survey(namcs2019sv)
    -#> * Mode: General.
     #>                         Survey info {NAMCS 2019 PUF}                         
     #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
     #> │ Variables │ Observations │ Design                                         │
    diff --git a/docs/reference/var_not.html b/docs/reference/var_not.html
    index cc6f6a8..aa382b6 100644
    --- a/docs/reference/var_not.html
    +++ b/docs/reference/var_not.html
    @@ -98,7 +98,6 @@ 

    See also

    Examples

    set_survey(namcs2019sv)
    -#> * Mode: General.
     #>                         Survey info {NAMCS 2019 PUF}                         
     #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
     #> │ Variables │ Observations │ Design                                         │
    diff --git a/docs/search.json b/docs/search.json
    index d7541d6..ebee233 100644
    --- a/docs/search.json
    +++ b/docs/search.json
    @@ -1 +1 @@
    -[{"path":"https://cdcgov.github.io/surveytable/articles/Advanced-topics.html","id":"subsetting-a-survey","dir":"Articles","previous_headings":"","what":"Subsetting a survey","title":"Advanced topics","text":"Consider example, estimate number medications age group: Survey info {NAMCS 2019 PUF} Number medications coded (different levels Patient age recode) {NAMCS 2019 PUF} ’d like estimate thing, visits NUMMED > 0? One way create another survey object NUMMED > 0, analyze new survey object. Survey info {NAMCS 2019 PUF: NUMMED 1+} Note called set_survey(), let R know now want analyze new object newsurvey, namcs2019sv. Now, let’s create table: Number medications coded (different levels Patient age recode) {NAMCS 2019 PUF: NUMMED 1+} sure check table title verify tabulating new survey object.","code":"library(surveytable) set_survey(namcs2019sv) tab_subset(\"NUMMED\", \"AGER\") newsurvey = survey_subset(namcs2019sv, NUMMED > 0   , label = \"NAMCS 2019 PUF: NUMMED 1+\") set_survey(newsurvey) ## * Mode: General. tab_subset(\"NUMMED\", \"AGER\")"},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/articles/Advanced-topics.html","id":"advanced-variable-editing","dir":"Articles","previous_headings":"Advanced variable editing and data flow","what":"Advanced variable editing","title":"Advanced topics","text":"First, let’s review call “advanced variable editing”. surveytable provides number functions create modify survey variables. examples include [var_collapse()] [var_cut()]. Occasionally, might need advanced variable editing. ’s : Every survey object element called variables data frame survey’s variables located Create new variable variables data frame (part survey object). Call set_survey() . time modify variables data frame, call set_survey(). Tabulate new variable. example , see vignette(\"Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report\").","code":""},{"path":"https://cdcgov.github.io/surveytable/articles/Advanced-topics.html","id":"data-flow","dir":"Articles","previous_headings":"Advanced variable editing and data flow","what":"Data flow","title":"Advanced topics","text":"explanation raises question set_survey() must called , variables modified. explanation: survey ’re analyzing actually exists three separate places: file computer data storage contains survey object. example, RDS file hard disk drive contains survey object named something like mysurvey.rds. survey object R’s global environment, named something like mysurvey. hidden copy survey object ’s used surveytable. surveytable analyzes. (3) ’s different (2), might ask. ’s due arcane issue R packages work – (2) (3) necessary. Normally, information flows forwards, (1) (2) (2) (3). Forwards flow: Going (1) (2): call readRDS(). Going (2) (3): call set_survey(). Backwards flow: Going (3) (2): probably don’t need , see . really need , call surveytable:::.load_survey(). Going (2) (1): call saveRDS(). Normally, probably don’t want . Normally, survey file (mysurvey.rds) probably changed. functions modifying creating variables part surveytable package (like var_cut() var_collapse()) modify (3). Since (3) surveytable works tabulates, can call var_collapse(), can call tab(). don’t need anything extra . modifying variables data frame directly, actually modifying (2). modify (2), need copy (3), surveytable can use . calling set_survey(). Thus, time modify variables , call set_survey(). modify (2), copy (2) -> (3) calling set_survey(). flip side, changes make (3) (using surveytable functions like var_cut() var_collapse()) reflected (2). make changes (3), call set_survey(), changes lost, set_survey() copies (2) -> (3). changes important, can just rerun code created . really need go (3) (2), use mysurvey = surveytable:::.load_survey().","code":""},{"path":"https://cdcgov.github.io/surveytable/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html","id":"begin","dir":"Articles","previous_headings":"","what":"Begin","title":"Example: National Ambulatory Medical Care Survey (NAMCS) tables","text":"Begin loading surveytable package. , print message explaining specify survey ’d like analyze. omitting message . Now, specify survey ’d like analyze. Survey info {NAMCS 2019 PUF} Check survey name, survey design variables, number observations verify looks correct. example, want turn certain NCHS-specific options, identifying low-precision estimates. care identifying low-precision estimates, can skip command. turn NCHS-specific options:","code":"library(surveytable) set_survey(namcs2019sv) ## * Mode: General. set_mode(\"NCHS\") ## * Mode: NCHS."},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html","id":"counts-and-percentages","dir":"Articles","previous_headings":"Table 1","what":"Counts and percentages","title":"Example: National Ambulatory Medical Care Survey (NAMCS) tables","text":"table shows overall estimated count well counts percentages type doctor, physician specialty, metropolitan statistical area. variables necessary creating table already survey, making commands straightforward. Total {NAMCS 2019 PUF} Type doctor (MD ) {NAMCS 2019 PUF} Type specialty (Primary, Medical, Surgical) {NAMCS 2019 PUF} Metropolitan Statistical Area Status physician location {NAMCS 2019 PUF}","code":"total() tab(\"MDDO\", \"SPECCAT\", \"MSA\")"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html","id":"rates","dir":"Articles","previous_headings":"Table 1","what":"Rates","title":"Example: National Ambulatory Medical Care Survey (NAMCS) tables","text":"published table also shows several rates. calculate rates, addition survey, need source information population estimates. typically use function read.csv() load population estimates get correct format. surveytable package comes object called uspop2019 contains several population estimates use examples. overall population estimate: overall population estimate, overall rate : Total (rate per 100 population) {NAMCS 2019 PUF} calculate rates particular variable, need provide data frame variable called Level matches levels variable survey, variable called Population gives population size (assumed constant rather random variable). MSA, can see levels variables just using tab() command, just . Thus, calculate rates, need data frame follows: Now appropriate population estimates, rate : Metropolitan Statistical Area Status physician location (rate per 100 population) {NAMCS 2019 PUF} can also calculate rates specific variable based entire population: Type doctor (MD ) (rate per 100 population) {NAMCS 2019 PUF} Type specialty (Primary, Medical, Surgical) (rate per 100 population) {NAMCS 2019 PUF}","code":"class(uspop2019) ## [1] \"list\" names(uspop2019) ## [1] \"total\"       \"MSA\"         \"AGER\"        \"Age group\"   \"SEX\"         ## [6] \"AGER x SEX\"  \"Age group 5\" uspop2019$total ## [1] 323186697 total_rate(uspop2019$total) uspop2019$MSA ##                                 Level Population ## 1 MSA (Metropolitan Statistical Area)  277229518 ## 2                             Non-MSA   45957179 tab_rate(\"MSA\", uspop2019$MSA) tab_rate(\"MDDO\", uspop2019$total) ## * Rate based on the entire population. tab_rate(\"SPECCAT\", uspop2019$total) ## * Rate based on the entire population."},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html","id":"counts-and-percentages-1","dir":"Articles","previous_headings":"Table 3","what":"Counts and percentages","title":"Example: National Ambulatory Medical Care Survey (NAMCS) tables","text":"table presents estimates age group, well age group sex. Variables beginning ‘age’ {NAMCS 2019 PUF} survey couple relevant age-related variables. AGE patient age years. AGER categorical variable based AGE. However, table, addition AGER, need another age group variable, different age categories. create using var_cut function. Now ’ve created Age group variable, can create tables: Patient age recode {NAMCS 2019 PUF} Age group {NAMCS 2019 PUF} Patient sex {NAMCS 2019 PUF} (Patient age recode) x (Patient sex) {NAMCS 2019 PUF}","code":"var_list(\"age\") var_cut(\"Age group\", \"AGE\"         , c(-Inf, 0, 4, 14, 64, Inf)         , c(\"Under 1\", \"1-4\", \"5-14\", \"15-64\", \"65 and over\") ) tab(\"AGER\", \"Age group\", \"SEX\") tab_cross(\"AGER\", \"SEX\")"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html","id":"rates-1","dir":"Articles","previous_headings":"Table 3","what":"Rates","title":"Example: National Ambulatory Medical Care Survey (NAMCS) tables","text":"Patient age recode (rate per 100 population) {NAMCS 2019 PUF} Age group (rate per 100 population) {NAMCS 2019 PUF} Patient sex (rate per 100 population) {NAMCS 2019 PUF} calculate rates one variable (AGER) another variable (SEX), need population estimates following format: population estimates, rates : Patient age recode (Patient sex = Female) (rate per 100 population) {NAMCS 2019 PUF} Patient age recode (Patient sex = Male) (rate per 100 population) {NAMCS 2019 PUF}","code":"tab_rate(\"AGER\", uspop2019$AGER) tab_rate(\"Age group\", uspop2019$`Age group`) ## * Population for some levels not defined: 15-64 tab_rate(\"SEX\", uspop2019$SEX) uspop2019$`AGER x SEX` ##                Level Subset Population ## 1     Under 15 years Female   29604762 ## 2        15-24 years Female   20730118 ## 3        25-44 years Female   43192143 ## 4        45-64 years Female   42508901 ## 5        65-74 years Female   16673240 ## 6  75 years and over Female   12421444 ## 7     Under 15 years   Male   30921894 ## 8        15-24 years   Male   20988582 ## 9        25-44 years   Male   42407267 ## 10       45-64 years   Male   40053148 ## 11       65-74 years   Male   14586962 ## 12 75 years and over   Male    9098236 tab_subset_rate(\"AGER\", \"SEX\", uspop2019$`AGER x SEX`)"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html","id":"table-5","dir":"Articles","previous_headings":"","what":"Table 5","title":"Example: National Ambulatory Medical Care Survey (NAMCS) tables","text":"table gives expected sources payment. use PAY* variables create several new variables required table. Note PAY* variables logical (TRUE FALSE), simplifies workflow. (survey imported R using importsurvey package, automatically detects binary variables imports logical variables.) Expected source payment visit: Private insurance {NAMCS 2019 PUF} Expected source payment visit: Medicare {NAMCS 2019 PUF} Expected source payment visit: Medicaid CHIP state-based program {NAMCS 2019 PUF} Medicare Medicaid {NAMCS 2019 PUF} insurance {NAMCS 2019 PUF} Self-pay {NAMCS 2019 PUF} charge {NAMCS 2019 PUF} Expected source payment visit: Workers Compensation {NAMCS 2019 PUF} Expected source payment visit: {NAMCS 2019 PUF} Unknown blank {NAMCS 2019 PUF} Check presentation standards flags! NCHS presentation standards rules, estimates shown.","code":"# var_all(\"Medicare and Medicaid\", c(\"PAYMCARE\", \"PAYMCAID\"))  # var_any(\"Payment used\", c(\"PAYPRIV\", \"PAYMCARE\", \"PAYMCAID\"   , \"PAYWKCMP\", \"PAYOTH\", \"PAYDK\")) var_not(\"No other payment used\", \"Payment used\")  var_all(\"Self-pay\", c(\"PAYSELF\", \"No other payment used\")) var_all(\"No charge\", c(\"PAYNOCHG\", \"No other payment used\")) var_any(\"No insurance\", c(\"Self-pay\", \"No charge\"))  # var_case(\"No pay\", \"NOPAY\", \"No categories marked\") var_any(\"Unknown or blank\", c(\"PAYDK\", \"No pay\"))  ## tab(\"PAYPRIV\", \"PAYMCARE\", \"PAYMCAID\", \"Medicare and Medicaid\"   , \"No insurance\", \"Self-pay\", \"No charge\"   , \"PAYWKCMP\", \"PAYOTH\", \"Unknown or blank\")"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html","id":"table-6","dir":"Articles","previous_headings":"","what":"Table 6","title":"Example: National Ambulatory Medical Care Survey (NAMCS) tables","text":"table shows primary care provider referral status, prior-visit status. table, “Unknown” “Blank” values collapsed single value. can collapse two levels factor single level using var_collapse function. Now, table: patient’s primary care provider? {NAMCS 2019 PUF} patient referred visit? {NAMCS 2019 PUF} patient seen practice ? {NAMCS 2019 PUF} percentages within subset defined SENBEFOR add 100% – reason, want use tab_subset(), tab_cross(). patient’s primary care provider? (patient seen practice ? = Yes, established patient) {NAMCS 2019 PUF} patient’s primary care provider? (patient seen practice ? = , new patient) {NAMCS 2019 PUF} patient referred visit? (patient seen practice ? = Yes, established patient) {NAMCS 2019 PUF} patient referred visit? (patient seen practice ? = , new patient) {NAMCS 2019 PUF}","code":"var_collapse(\"PRIMCARE\", \"Unknown if PCP\", c(\"Unknown\", \"Blank\")) var_collapse(\"REFER\", \"Unknown if referred\", c(\"Unknown\", \"Blank\")) tab(\"PRIMCARE\", \"REFER\", \"SENBEFOR\") tab_subset(\"PRIMCARE\", \"SENBEFOR\") tab_subset(\"REFER\", \"SENBEFOR\")"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html","id":"table-11","dir":"Articles","previous_headings":"","what":"Table 11","title":"Example: National Ambulatory Medical Care Survey (NAMCS) tables","text":"table shows information Table 3, preventive care visits. , estimates age group, well age group sex, preventive care visits. Let’s create Age group AGE cross AGER SEX create variable called Age x Sex: see possible values MAJOR (Major reason visit), estimate total count preventive care visits: Major reason visit {NAMCS 2019 PUF} create tables age, sex, interaction, limit preventive care visits: Patient age recode (Major reason visit = Preventive care) {NAMCS 2019 PUF} Age group (Major reason visit = Preventive care) {NAMCS 2019 PUF} Patient sex (Major reason visit = Preventive care) {NAMCS 2019 PUF} Age x Sex (Major reason visit = Preventive care) {NAMCS 2019 PUF} commands similar, differs first variable passed tab_subset() function, code can streamlined loop: Patient age recode (Major reason visit = Preventive care) {NAMCS 2019 PUF} Age group (Major reason visit = Preventive care) {NAMCS 2019 PUF} Patient sex (Major reason visit = Preventive care) {NAMCS 2019 PUF} Age x Sex (Major reason visit = Preventive care) {NAMCS 2019 PUF} Note called inside loop, print() function needs called explicitly.","code":"var_cut(\"Age group\", \"AGE\"         , c(-Inf, 0, 4, 14, 64, Inf)         , c(\"Under 1\", \"1-4\", \"5-14\", \"15-64\", \"65 and over\") ) ## Warning in var_cut(\"Age group\", \"AGE\", c(-Inf, 0, 4, 14, 64, Inf), c(\"Under 1\", ## : Age group: overwriting a variable that already exists. var_cross(\"Age x Sex\", \"AGER\", \"SEX\") tab(\"MAJOR\") tab_subset(\"AGER\", \"MAJOR\", \"Preventive care\") tab_subset(\"Age group\", \"MAJOR\", \"Preventive care\") tab_subset(\"SEX\", \"MAJOR\", \"Preventive care\") tab_subset(\"Age x Sex\", \"MAJOR\", \"Preventive care\") for (vr in c(\"AGER\", \"Age group\", \"SEX\", \"Age x Sex\")) {     print( tab_subset(vr, \"MAJOR\", \"Preventive care\") ) }"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html","id":"more-advanced-coding","dir":"Articles","previous_headings":"Table 11","what":"More advanced coding","title":"Example: National Ambulatory Medical Care Survey (NAMCS) tables","text":"addition, age-sex category, published table shows percentage preventive care visits made primary care physicians. calculate percentages, slightly involved loop needed. code, followed explanation: Since tab_subset() called within loop, wanted print screen, need use print( tab_subset(*) ). Since don’t want print screen, call print() omitted. Since many tables produced, output sent CSV file. , loop goes age, sex, age / sex interaction variables, calling variables vr. MAJOR vr crossed, result stored variable called tmp. Next, inner loop goes levels vr, calling levels lvl. code tabulates SPECCAT (Type specialty – Primary, Medical, Surgical) subset tmp (MAJOR crossed vr) restricted \"Preventive care: \" followed lvl, level vr, “15 years” AGER. Finally, CSV output turned . run code, tables stored CSV file. give idea tables look like, just one tables: Type specialty (Primary, Medical, Surgical) (tmp = Preventive care: 15 years) {NAMCS 2019 PUF} match percentage published table, see “Primary care specialty” row. sure check presentation standards flags.","code":"tmp_file = tempfile(fileext = \".csv\") suppressMessages( set_output(csv = tmp_file) )  for (vr in c(\"AGER\", \"Age group\", \"SEX\", \"Age x Sex\")) {     var_cross(\"tmp\", \"MAJOR\", vr)     for (lvl in levels(surveytable:::env$survey$variables[,vr])) {         tab_subset(\"SPECCAT\", \"tmp\", paste0(\"Preventive care: \", lvl))     } } ## Warning in var_cross(\"tmp\", \"MAJOR\", vr): tmp: overwriting a variable that ## already exists. ## Warning in var_cross(\"tmp\", \"MAJOR\", vr): tmp: overwriting a variable that ## already exists. ## Warning in var_cross(\"tmp\", \"MAJOR\", vr): tmp: overwriting a variable that ## already exists. set_output(csv = \"\") ## * Turning off CSV output. ## * ?set_output for other options. vr = \"AGER\" var_cross(\"tmp\", \"MAJOR\", vr) ## Warning in var_cross(\"tmp\", \"MAJOR\", vr): tmp: overwriting a variable that ## already exists. lvl = levels(surveytable:::env$survey$variables[,vr])[1] tab_subset(\"SPECCAT\", \"tmp\", paste0(\"Preventive care: \", lvl))"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report.html","id":"begin","dir":"Articles","previous_headings":"","what":"Begin","title":"Example: Residential Care Community Services User (NSLTCP RCC SU) report","text":"Begin loading surveytable package. , print message explaining specify survey ’d like analyze. Now, specify survey ’d like analyze. Survey info {RCC SU 2018 PUF} Check survey name, survey design variables, number observations verify looks correct. example, want turn certain NCHS-specific options, identifying low-precision estimates. care identifying low-precision estimates, can skip command. turn NCHS-specific options: Alternatively, can combine two commands single command, like : Survey info {RCC SU 2018 PUF}","code":"library(surveytable) set_survey(rccsu2018) ## * Mode: General. set_mode(\"NCHS\") ## * Mode: NCHS. set_survey(rccsu2018, mode = \"NCHS\") ## * Mode: NCHS."},{"path":"https://cdcgov.github.io/surveytable/articles/Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report.html","id":"figure-1","dir":"Articles","previous_headings":"","what":"Figure 1","title":"Example: Residential Care Community Services User (NSLTCP RCC SU) report","text":"figure shows percentage residents sex, race / ethnicity, age group. Sex. Resident’s gender {RCC SU 2018 PUF} Race / ethnicity. Variables beginning ‘race’ {RCC SU 2018 PUF} Resident’s race/ethnicity {RCC SU 2018 PUF} published figure, Hispanic categories merged single category called “Another race ethnicity”. can using var_collapse() function. Resident’s race/ethnicity {RCC SU 2018 PUF} Age group. Variables beginning ‘age’ {RCC SU 2018 PUF} age2 numeric variable. need create categorical variable based numeric variable. done using var_cut() function. Age {RCC SU 2018 PUF}","code":"tab(\"sex\") var_list(\"race\") tab(\"raceeth2\") var_collapse(\"raceeth2\"              , \"Another race or ethnicity\"              , c(\"Hispanic\", \"Other\")) tab(\"raceeth2\") var_list(\"age\") var_cut(\"Age\", \"age2\"         , c(-Inf, 64, 74, 84, Inf)         , c(\"Under 65\", \"65-74\", \"75-84\", \"85 and over\") ) tab(\"Age\")"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report.html","id":"figure-2","dir":"Articles","previous_headings":"","what":"Figure 2","title":"Example: Residential Care Community Services User (NSLTCP RCC SU) report","text":"figure shows percentage residents Medicaid, overall age group. Used Medicaid pay services {RCC SU 2018 PUF} can see, observations, value variable unknown (’s missing NA). command calculates percentages based observations, including ones missing (NA) values. However, published figure, percentages based knowns . exclude NA’s calculation, use drop_na argument: Used Medicaid pay services (knowns ) {RCC SU 2018 PUF} Note table title alerts fact using known values . age group: Used Medicaid pay services (Age = 65) (knowns ) {RCC SU 2018 PUF} Used Medicaid pay services (Age = 65-74) (knowns ) {RCC SU 2018 PUF} Used Medicaid pay services (Age = 75-84) (knowns ) {RCC SU 2018 PUF} Used Medicaid pay services (Age = 85 ) (knowns ) {RCC SU 2018 PUF} Note according NCHS presentation criteria, percentages suppressed.","code":"tab(\"medicaid2\") tab(\"medicaid2\", drop_na = TRUE) tab_subset(\"medicaid2\", \"Age\", drop_na = TRUE)"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report.html","id":"figure-4","dir":"Articles","previous_headings":"","what":"Figure 4","title":"Example: Residential Care Community Services User (NSLTCP RCC SU) report","text":"(Figure 3 slightly involved, ’ll next.) figure shows percentage residents one select set chronic conditions. addition, shows distribution residents number conditions. ’s table high blood pressure. Resident diagnosed high blood pressure {RCC SU 2018 PUF} , unknown values (NA) present, figure based knowns . Therefore, use drop_na argument: Resident diagnosed high blood pressure (knowns ) {RCC SU 2018 PUF} Resident diagnosed Alzheimer’s/dementia (knowns ) {RCC SU 2018 PUF} Resident diagnosed depression (knowns ) {RCC SU 2018 PUF} Resident diagnosed arthritis (knowns ) {RCC SU 2018 PUF} Resident diagnosed diabetes (knowns ) {RCC SU 2018 PUF} Resident diagnosed heart disease (knowns ) {RCC SU 2018 PUF} Resident diagnosed osteoporosis (knowns ) {RCC SU 2018 PUF} Resident diagnosed COPD (knowns ) {RCC SU 2018 PUF} Resident diagnosed stroke (knowns ) {RCC SU 2018 PUF} Resident diagnosed cancer (knowns ) {RCC SU 2018 PUF}","code":"tab(\"hbp\") tab(\"hbp\", \"alz\", \"depress\", \"arth\", \"diabetes\", \"heartdise\", \"osteo\"     , \"copd\", \"stroke\", \"cancer\"     , drop_na = TRUE)"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report.html","id":"advanced-variable-editing","dir":"Articles","previous_headings":"Figure 4","what":"Advanced variable editing","title":"Example: Residential Care Community Services User (NSLTCP RCC SU) report","text":"surveytable provides number functions create modify survey variables. saw couple : var_collapse() var_cut(). Occasionally, might need advanced variable editing. ’s : Every survey object element called variables data frame survey’s variables located Create new variable variables data frame (part survey object). Call set_survey() . time modify variables data frame, call set_survey(). Tabulate new variable. go steps count many chronic conditions present. Survey info {RCC SU 2018 PUF} num_cc numeric variable number chronic conditions. published figure uses categorical variable based numeric variable. Use var_cut(), converts numeric variables categorical (factor) variables. Number chronic conditions {RCC SU 2018 PUF}","code":"class(rccsu2018$variables) ## [1] \"data.frame\" rccsu2018$variables$num_cc = 0 for (vr in c(\"hbp\", \"alz\", \"depress\", \"arth\", \"diabetes\", \"heartdise\", \"osteo\"              , \"copd\", \"stroke\", \"cancer\")) {   idx = which(rccsu2018$variables[,vr])   rccsu2018$variables$num_cc[idx] = rccsu2018$variables$num_cc[idx] + 1 } set_survey(rccsu2018, mode = \"NCHS\") ## * Mode: NCHS. var_cut(\"Number of chronic conditions\", \"num_cc\"         , c(-Inf, 0, 1, 3, 10, Inf)         , c(\"0\", \"1\", \"2-3\", \"4-10\", \"??\")) tab(\"Number of chronic conditions\")"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report.html","id":"figure-3","dir":"Articles","previous_headings":"","what":"Figure 3","title":"Example: Residential Care Community Services User (NSLTCP RCC SU) report","text":"figure shows percentage residents need help one activities daily living (ADLs). addition, shows distribution residents number ADLs need help. ’s table bathhlp (help bathing): Type assistance resident needs bathe {RCC SU 2018 PUF} variable multiple levels. Several levels correspond resident needing help, One level (\"NEED ASSISTANCE\") = need help One level (\"MISSING\") = unknown want show (resident needing help) percentage knowns (, excluding unknowns). , convert variable 2 levels (needs help / need help) plus NA (unknown); use drop_na argument base percentages knowns . Type assistance resident needs bathe (knowns ) {RCC SU 2018 PUF} Type assistance resident needs locomotion (knowns ) {RCC SU 2018 PUF} Type assistance resident needs dress (knowns ) {RCC SU 2018 PUF} Type assistance resident needs transfer /chair (knowns ) {RCC SU 2018 PUF} Type assistance resident needs use bathroom (knowns ) {RCC SU 2018 PUF} Type assistance resident needs eat (knowns ) {RCC SU 2018 PUF} Now, go “advanced variable editing” steps – similar Figure 4 – count many ADLs present. Survey info {RCC SU 2018 PUF} generating figure, create categorical variable based num_adl, numeric. Number ADLs {RCC SU 2018 PUF}","code":"tab(\"bathhlp\") for (vr in c(\"bathhlp\", \"walkhlp\", \"dreshlp\", \"transhlp\", \"toilhlp\", \"eathlp\")) {   var_collapse(vr     , \"Needs assistance\"     , c(\"NEED HELP OR SUPERVISION FROM ANOTHER PERSON\"       , \"USE OF AN ASSISTIVE DEVICE\"       , \"BOTH\"))   var_collapse(vr, NA, \"MISSING\") }  tab(\"bathhlp\", \"walkhlp\", \"dreshlp\", \"transhlp\", \"toilhlp\", \"eathlp\", drop_na = TRUE) rccsu2018$variables$num_adl = 0 for (vr in c(\"bathhlp\", \"walkhlp\", \"dreshlp\", \"transhlp\", \"toilhlp\", \"eathlp\")) {   idx = which(rccsu2018$variables[,vr] %in%     c(\"NEED HELP OR SUPERVISION FROM ANOTHER PERSON\"       , \"USE OF AN ASSISTIVE DEVICE\"       , \"BOTH\"))   rccsu2018$variables$num_adl[idx] = rccsu2018$variables$num_adl[idx] + 1 } set_survey(rccsu2018, mode = \"NCHS\") ## * Mode: NCHS. var_cut(\"Number of ADLs\", \"num_adl\"         , c(-Inf, 0, 2, 6, Inf)         , c(\"0\", \"1-2\", \"3-6\", \"??\")) tab(\"Number of ADLs\")"},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"concepts","dir":"Articles","previous_headings":"Preliminaries","what":"Concepts","title":"Introduction to surveytable","text":"two important concepts need learn distinguish: data frame standard way storing data R. data frame rectangular data. Variables columns, observations rows. Example: data frame, , represent complex survey. , just looking data frame, R know sampling weights , strata , etc. Even variables represent sampling weights, etc, part data frame, just looking data frame, R know variable represents weights survey design variables. can get data frame R many different ways. data currently comma-separated values (CSV) file, can use read.csv(). ’s SAS file, can use package like haven importsurvey. ’s already R format, use readRDS(), . survey object object describes survey. tells R sampling weights , strata , . data frame can converted survey object using survey::svydesign() function; survey uses replicate weights, survey::svrepdesign() function used. Generally speaking, need convert data frame survey object . converted, can save saveRDS() (similar). future, can load readRDS(). need re-convert data frame survey object every time.","code":"head(iris) #>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> 1          5.1         3.5          1.4         0.2  setosa #> 2          4.9         3.0          1.4         0.2  setosa #> 3          4.7         3.2          1.3         0.2  setosa #> 4          4.6         3.1          1.5         0.2  setosa #> 5          5.0         3.6          1.4         0.2  setosa #> 6          5.4         3.9          1.7         0.4  setosa"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"namcs","dir":"Articles","previous_headings":"Preliminaries","what":"NAMCS","title":"Introduction to surveytable","text":"Examples tutorial use survey called National Ambulatory Medical Care Survey (NAMCS) 2019 Public Use File (PUF). NAMCS “annual nationally representative sample survey visits non-federal office-based patient care physicians, excluding anesthesiologists, radiologists, pathologists.” Note unit observation visits, patients – distinction important since single patient can make multiple visits. surveytable package comes data frame selected variables NAMCS, called namcs2019sv_df (sv = selected variables; df = data frame). survey object survey called namcs2019sv. namcs2019sv object analyze. really need namcs2019sv. reason package namcs2019sv_df illustrate convert data frame survey object.","code":""},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"more-concepts","dir":"Articles","previous_headings":"Preliminaries","what":"More concepts","title":"Introduction to surveytable","text":"importing data another source, SAS CSV, analysts aware standard way variables handled R. Specifically, categorical variables stored factor. true / false variables stored factor well, programming tasks easier stored logical. Unknown values stored missing (NA). variable contains “special values”, negative value indicating age missing, “special values” need converted NA. Variables namcs2019sv_df already stored correctly. Thus, AGER (patient’s age group) factor variable; PAYNOCHG (indicates whether charge physician visit) logical variable; AGE (patient’s age years) numeric variable.","code":"library(\"surveytable\") class(namcs2019sv_df$AGER) #> [1] \"factor\" class(namcs2019sv_df$PAYNOCHG) #> [1] \"logical\" class(namcs2019sv_df$AGE) #> [1] \"numeric\""},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"create-a-survey-object","dir":"Articles","previous_headings":"Preliminaries","what":"Create a survey object","title":"Introduction to surveytable","text":"seen , tables produced surveytable clearer either variable names descriptive, variables \"label\" attribute descriptive. namcs2019sv_df, variables already \"label\" attribute set. example, variable name AGE descriptive, variable descriptive \"label\" attribute: Documentation NAMCS survey provides names survey design variables. Specifically, NAMCS, cluster ID’s, also known primary sampling units (PSU’s), given CPSUM; strata given CSTRATM; sampling weights given PATWT. Thus, namcs2019sv_df data frame can turned survey object follows: Tables produced surveytable clearer either name survey object descriptive, object \"label\" attribute descriptive. Let’s set attribute mysurvey: mysurvey object now namcs2019sv. Let’s verify : just successfully created survey object data frame.","code":"attr(namcs2019sv_df$AGE, \"label\") #> [1] \"Patient age in years (raw - use caution)\" mysurvey = survey::svydesign(ids = ~ CPSUM   , strata = ~ CSTRATM   , weights = ~ PATWT   , data = namcs2019sv_df) attr(mysurvey, \"label\") = \"NAMCS 2019 PUF\" all.equal(namcs2019sv, mysurvey) #> [1] TRUE"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"begin-analysis","dir":"Articles","previous_headings":"","what":"Begin analysis","title":"Introduction to surveytable","text":"First, specify survey object ’d like analyze. Survey info {NAMCS 2019 PUF} Check survey label, survey design variables, number observations verify looks correct. example, want turn certain NCHS-specific options, identifying low-precision estimates. care identifying low-precision estimates, can skip command. turn NCHS-specific options:","code":"set_survey(namcs2019sv) #> * Mode: General. set_mode(\"NCHS\") #> * Mode: NCHS."},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"list-variables","dir":"Articles","previous_headings":"Begin analysis","what":"List variables","title":"Introduction to surveytable","text":"var_list() function lists variables survey. avoid unintentionally listing variables survey, can many, starting characters variable names specified. example, list variables start letters age, type: Variables beginning ‘age’ {NAMCS 2019 PUF} table lists variable name; class, type variable; variable label, long name variable. Common classes factor (categorical variable), logical (yes / variable), numeric.","code":"var_list(\"age\")"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"tabulate-categorical-and-logical-variables","dir":"Articles","previous_headings":"","what":"Tabulate categorical and logical variables","title":"Introduction to surveytable","text":"main function surveytable package tab(), tabulates variables. operates categorical logical variables, presents estimated counts, standard errors (SEs) 95% confidence intervals (CIs), percentages, SEs CIs. example, tabulate AGER, type: Patient age recode {NAMCS 2019 PUF} table title shows variable label (long variable name) survey label. level variable, table shows: estimated count, standard error, 95% confidence interval; estimated percentage, standard error, 95% confidence interval. NCHS presentation standards. tab() function also applies National Center Health Statistics (NCHS) presentation standards counts percentages, flags estimates , according standards, suppressed, footnoted, reviewed analyst. CIs displayed ones used NCHS presentation standards. Specifically, counts, tables show log Student’s t 95% CI, adaptations complex surveys; percentages, show 95% Korn Graubard CI. One need anything extra perform presentation standards checking – performed automatically. example, let’s tabulate PAYNOCHG: Expected source payment visit: Charge/Charity {NAMCS 2019 PUF} table tells us , according NCHS presentation standards, estimated number visits charge visit suppressed due low precision. However, lack percentage flag indicates estimated percentage visits can shown. Drop missing values. variables might contain missing values (NA). Consider following variable, part actual survey, constructed specifically example: Type specialty (BAD - use) {NAMCS 2019 PUF} calculate percentages based non-missing values , use drop_na argument: Type specialty (BAD - use) (knowns ) {NAMCS 2019 PUF} table gives percentages based knowns, , based non-NA values. Multiple tables. Multiple tables can created single command: Type doctor (MD ) {NAMCS 2019 PUF} Type specialty (Primary, Medical, Surgical) {NAMCS 2019 PUF} Metropolitan Statistical Area Status physician location {NAMCS 2019 PUF}","code":"tab(\"AGER\") tab(\"PAYNOCHG\") tab(\"SPECCAT.bad\") tab(\"SPECCAT.bad\", drop_na = TRUE) tab(\"MDDO\", \"SPECCAT\", \"MSA\")"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"entire-population","dir":"Articles","previous_headings":"Tabulate categorical and logical variables","what":"Entire population","title":"Introduction to surveytable","text":"Estimate total count entire population using total() command: Total {NAMCS 2019 PUF}","code":"total()"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"subsets-or-interactions","dir":"Articles","previous_headings":"Tabulate categorical and logical variables","what":"Subsets or interactions","title":"Introduction to surveytable","text":"create table AGER value variable SEX, type: Patient age recode (Patient sex = Female) {NAMCS 2019 PUF} Patient age recode (Patient sex = Male) {NAMCS 2019 PUF} addition giving long name variable tabulated, title table reflects value subsetting variable (case, either Female Male). tab_subset() command, table (, subset), percentages add 100%. tab_cross() function similar – crosses interacts two variables generates table using new variable. Thus, create table interaction AGER SEX, type: (Patient age recode) x (Patient sex) {NAMCS 2019 PUF} estimated counts produced tab_subset() tab_cross() , percentages different. tab_subset() command, within table (, within subset), percentages add 100%. hand, tab_cross(), percentages across entire population add 100%.","code":"tab_subset(\"AGER\", \"SEX\") tab_cross(\"AGER\", \"SEX\")"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"tabulate-numeric-variables","dir":"Articles","previous_headings":"","what":"Tabulate numeric variables","title":"Introduction to surveytable","text":"tab() tab_subset() functions also work numeric variables, though variables, output different. tabulate NUMMED (number medications), numeric variable, type: Number medications coded {NAMCS 2019 PUF} , table title shows variable label (long variable name) survey label. table shows percentage values missing (NA), mean, standard error mean (SEM), standard deviation (SD). Subsetting works : Number medications coded (different levels Patient age recode) {NAMCS 2019 PUF}","code":"tab(\"NUMMED\") tab_subset(\"NUMMED\", \"AGER\")"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"perform-statistical-hypothesis-testing","dir":"Articles","previous_headings":"","what":"Perform statistical hypothesis testing","title":"Introduction to surveytable","text":"tab_subset() function makes easy perform hypothesis testing using test argument. argument TRUE, test association performed. addition, t-tests pairs levels performed well.","code":""},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"categorical-variables","dir":"Articles","previous_headings":"Perform statistical hypothesis testing","what":"Categorical variables","title":"Introduction to surveytable","text":"Consider relationship AGER SPECCAT: Patient age recode (Type specialty (Primary, Medical, Surgical) = Primary care specialty) {NAMCS 2019 PUF} Patient age recode (Type specialty (Primary, Medical, Surgical) = Surgical care specialty) {NAMCS 2019 PUF} Patient age recode (Type specialty (Primary, Medical, Surgical) = Medical care specialty) {NAMCS 2019 PUF} Association Patient age recode Type specialty (Primary, Medical, Surgical) {NAMCS 2019 PUF} Comparison possible pairs Patient age recode (Type specialty (Primary, Medical, Surgical) = Primary care specialty) {NAMCS 2019 PUF} Comparison possible pairs Patient age recode (Type specialty (Primary, Medical, Surgical) = Surgical care specialty) {NAMCS 2019 PUF} Comparison possible pairs Patient age recode (Type specialty (Primary, Medical, Surgical) = Medical care specialty) {NAMCS 2019 PUF} Comparison possible pairs Type specialty (Primary, Medical, Surgical) (Patient age recode = 15 years) {NAMCS 2019 PUF} Comparison possible pairs Type specialty (Primary, Medical, Surgical) (Patient age recode = 15-24 years) {NAMCS 2019 PUF} Comparison possible pairs Type specialty (Primary, Medical, Surgical) (Patient age recode = 25-44 years) {NAMCS 2019 PUF} Comparison possible pairs Type specialty (Primary, Medical, Surgical) (Patient age recode = 45-64 years) {NAMCS 2019 PUF} Comparison possible pairs Type specialty (Primary, Medical, Surgical) (Patient age recode = 65-74 years) {NAMCS 2019 PUF} Comparison possible pairs Type specialty (Primary, Medical, Surgical) (Patient age recode = 75 years ) {NAMCS 2019 PUF} According tables, association physician specialty type patient age. instance, patients 15 years, statistical difference primary care physician specialty medical care specialty. older patients, 45-64 age group, statistical difference two specialty types. another example, consider relationship MRI SPECCAT: MRI (Type specialty (Primary, Medical, Surgical) = Primary care specialty) {NAMCS 2019 PUF} MRI (Type specialty (Primary, Medical, Surgical) = Surgical care specialty) {NAMCS 2019 PUF} MRI (Type specialty (Primary, Medical, Surgical) = Medical care specialty) {NAMCS 2019 PUF} Association MRI Type specialty (Primary, Medical, Surgical) {NAMCS 2019 PUF} Comparison possible pairs MRI (Type specialty (Primary, Medical, Surgical) = Primary care specialty) {NAMCS 2019 PUF} Comparison possible pairs MRI (Type specialty (Primary, Medical, Surgical) = Surgical care specialty) {NAMCS 2019 PUF} Comparison possible pairs MRI (Type specialty (Primary, Medical, Surgical) = Medical care specialty) {NAMCS 2019 PUF} Comparison possible pairs Type specialty (Primary, Medical, Surgical) (MRI = FALSE) {NAMCS 2019 PUF} Comparison possible pairs Type specialty (Primary, Medical, Surgical) (MRI = TRUE) {NAMCS 2019 PUF} According tables, statistical association MRI physician specialty. 3 specialty types, minority visits MRI’s. visits MRI’s, statistical difference specialty types. general rule thumb, since statistical association MRI physician specialty, presenting tabulation particularly interesting, especially since subsetting decreases sample size therefore also decreases estimate reliability. Instead, generally make sense just tabulate MRI without subsetting SPECCAT.","code":"tab_subset(\"AGER\", \"SPECCAT\", test = TRUE) tab_subset(\"MRI\", \"SPECCAT\", test = TRUE)"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"numeric-variables","dir":"Articles","previous_headings":"Perform statistical hypothesis testing","what":"Numeric variables","title":"Introduction to surveytable","text":"relationship NUMMED AGER: Number medications coded (different levels Patient age recode) {NAMCS 2019 PUF} Association Number medications coded Patient age recode {NAMCS 2019 PUF} Comparison Number medications coded across possible pairs Patient age recode {NAMCS 2019 PUF} According tables, association number medications age category. NUMMED statistically similar “15 years” “15-24 years” AGER categories. statistically different pairs age categories. Finally, let’s look relationship NUMMED SPECCAT: Number medications coded (different levels Type specialty (Primary, Medical, Surgical)) {NAMCS 2019 PUF} Association Number medications coded Type specialty (Primary, Medical, Surgical) {NAMCS 2019 PUF} Comparison Number medications coded across possible pairs Type specialty (Primary, Medical, Surgical) {NAMCS 2019 PUF} According tables, association number medications physician specialty type. NUMMED statistically similar pairs physician specialties. general rule thumb, since statistical association number medications physician specialty, presenting tabulation particularly interesting, especially since subsetting decreases sample size therefore also decreases estimate reliability. Instead, generally make sense just tabulate NUMMED without subsetting SPECCAT.","code":"tab_subset(\"NUMMED\", \"AGER\", test = TRUE) tab_subset(\"NUMMED\", \"SPECCAT\", test = TRUE)"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"categorical-variables-single-variable","dir":"Articles","previous_headings":"Perform statistical hypothesis testing","what":"Categorical variables (single variable)","title":"Introduction to surveytable","text":"test whether pair SPECCAT levels statistically similar different, type: Type specialty (Primary, Medical, Surgical) {NAMCS 2019 PUF} Comparison possible pairs Type specialty (Primary, Medical, Surgical) {NAMCS 2019 PUF} According , surgical medical care specialties statistically similar, statistically different primary care.","code":"tab(\"SPECCAT\", test = TRUE)"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"calculate-rates","dir":"Articles","previous_headings":"","what":"Calculate rates","title":"Introduction to surveytable","text":"rate ratio count estimates based survey question divided population size, assumed known. example, number physician visits per 100 people population rate: number physician visits estimated namcs2019sv survey, number people population comes another source. calculate rates, addition survey, need source information population size. typically use function read.csv() load population figures get correct format. surveytable package comes object called uspop2019 contains several population figures use examples. Let’s examine uspop2019: overall population size country whole : overall population size, overall rate : Total (rate per 100 population) {NAMCS 2019 PUF} calculate rates particular variable, need provide data frame column called Level matches levels variable survey, column called Population gives size population level. example, AGER, data frame follows: Now appropriate population figures, rates table obtained typing: Patient age recode (rate per 100 population) {NAMCS 2019 PUF} calculate rates one variable (AGER) another variable (SEX), need population figures following format: data frame, rates table obtained typing: Patient age recode (Patient sex = Female) (rate per 100 population) {NAMCS 2019 PUF} Patient age recode (Patient sex = Male) (rate per 100 population) {NAMCS 2019 PUF}","code":"class(uspop2019) #> [1] \"list\" names(uspop2019) #> [1] \"total\"       \"MSA\"         \"AGER\"        \"Age group\"   \"SEX\"         #> [6] \"AGER x SEX\"  \"Age group 5\" uspop2019$total #> [1] 323186697 total_rate(uspop2019$total) uspop2019$AGER #>               Level Population #> 1    Under 15 years   60526656 #> 2       15-24 years   41718700 #> 3       25-44 years   85599410 #> 4       45-64 years   82562049 #> 5       65-74 years   31260202 #> 6 75 years and over   21519680 tab_rate(\"AGER\", uspop2019$AGER) uspop2019$`AGER x SEX` #>                Level Subset Population #> 1     Under 15 years Female   29604762 #> 2        15-24 years Female   20730118 #> 3        25-44 years Female   43192143 #> 4        45-64 years Female   42508901 #> 5        65-74 years Female   16673240 #> 6  75 years and over Female   12421444 #> 7     Under 15 years   Male   30921894 #> 8        15-24 years   Male   20988582 #> 9        25-44 years   Male   42407267 #> 10       45-64 years   Male   40053148 #> 11       65-74 years   Male   14586962 #> 12 75 years and over   Male    9098236 tab_subset_rate(\"AGER\", \"SEX\", uspop2019$`AGER x SEX`)"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"create-or-modify-variables","dir":"Articles","previous_headings":"","what":"Create or modify variables","title":"Introduction to surveytable","text":"situations, might necessary modify survey variables, create new ones. section describes . Convert factor logical. variable MAJOR (major reason visit) several levels. Major reason visit {NAMCS 2019 PUF} Notice one levels called \"Preventive care\". Suppose analyst interested whether visit preventive care visit – interested visit types. can create new variable called Preventive care visits TRUE preventive care visits FALSE types visits, follows: Preventive care visits {NAMCS 2019 PUF} creates logical variable TRUE preventive care visits tabulates . using var_case() function, specify name new logical variable created, existing factor variable, one levels factor variable set TRUE logical variable. Thus, analyst interested surgery-related visits, indicated two different levels MAJOR, type: Surgery-related visits {NAMCS 2019 PUF} Collapse levels. variable PRIMCARE (whether physician patient’s primary care provider) levels Unknown Blank, among others. patient’s primary care provider? {NAMCS 2019 PUF} collapse Unknown Blank single level, type: patient’s primary care provider? {NAMCS 2019 PUF} Convert numeric factor. variable AGE numeric. Patient age years (raw - use caution) {NAMCS 2019 PUF} create new variable age categories based AGE, type: Age group {NAMCS 2019 PUF} var_cut() command, specify following information: name new categorical variable; name existing numeric variable; cut points – note intervals inclusive right; category labels. cognizant “special values” numeric variable might . data systems, negative values indicate unknowns, coded NA. ’s – value -Inf -0.1 gets coded missing (NA). Though particular data, unknowns “special values”. Check whether variable true. series logical variables, can check whether TRUE using var_any() command. physician visit considered “imaging services” visit number imaging services ordered provided. Imaging services indicated using logical variables, MRI XRAY. create Imaging services variable, type: Imaging services {NAMCS 2019 PUF} Interact variables. tab_cross() function creates table interaction two variables, save interacted variable. create interacted variable, use var_cross() command: Specify name new variable well names two variables interact. Copy variable. Create new variable copy another variable using var_copy(). can modify copy, original remains unchanged. example: Patient age recode {NAMCS 2019 PUF} Age group {NAMCS 2019 PUF} , AGER variable remains unchanged, Age group variable fewer categories.","code":"tab(\"MAJOR\") var_case(\"Preventive care visits\", \"MAJOR\", \"Preventive care\") tab(\"Preventive care visits\") var_case(\"Surgery-related visits\"   , \"MAJOR\"   , c(\"Pre-surgery\", \"Post-surgery\")) tab(\"Surgery-related visits\") tab(\"PRIMCARE\") var_collapse(\"PRIMCARE\", \"Unknown if PCP\", c(\"Unknown\", \"Blank\")) tab(\"PRIMCARE\") tab(\"AGE\") var_cut(\"Age group\"    , \"AGE\"    , c(-Inf, -0.1, 0, 4, 14, 64, Inf)    , c(NA, \"Under 1\", \"1-4\", \"5-14\", \"15-64\", \"65 and over\")) tab(\"Age group\") var_any(\"Imaging services\"   , c(\"ANYIMAGE\", \"BONEDENS\", \"CATSCAN\", \"ECHOCARD\", \"OTHULTRA\"   , \"MAMMO\", \"MRI\", \"XRAY\", \"OTHIMAGE\")) tab(\"Imaging services\") var_cross(\"Age x Sex\", \"AGER\", \"SEX\") var_copy(\"Age group\", \"AGER\") #> Warning in var_copy(\"Age group\", \"AGER\"): Age group: overwriting a variable #> that already exists. var_collapse(\"Age group\", \"65+\", c(\"65-74 years\", \"75 years and over\")) var_collapse(\"Age group\", \"25-64\", c(\"25-44 years\", \"45-64 years\")) tab(\"AGER\", \"Age group\")"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"save-the-output","dir":"Articles","previous_headings":"","what":"Save the output","title":"Introduction to surveytable","text":"tab* total* functions argument called csv specifies name comma-separated values (CSV) file save output . Alternatively, can name default CSV output file using set_output() function. example, following directs surveytable send future output CSV file, create tables, turn sending output file: Type doctor (MD ) {NAMCS 2019 PUF} Type specialty (Primary, Medical, Surgical) {NAMCS 2019 PUF} Metropolitan Statistical Area Status physician location {NAMCS 2019 PUF} tabulation functions called within R Markdown notebook Quarto document, produce HTML LaTeX tables, appropriate. makes easy incorporate output surveytable package directly documents, presentations, “shiny” web apps, output types. Finally, tabulation functions return tables produce. advanced analysts can use functionality integrate surveytable programming tasks.","code":"set_output(csv = \"output.csv\") tab(\"MDDO\", \"SPECCAT\", \"MSA\") set_output(csv = \"\") #> * Turning off CSV output. #> * ?set_output for other options."},{"path":"https://cdcgov.github.io/surveytable/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Alex Strashny. Author, maintainer.","code":""},{"path":"https://cdcgov.github.io/surveytable/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Strashny (2023). surveytable: Formatted Survey Estimates. doi:10.32614/CRAN.package.surveytable, https://cdcgov.github.io/surveytable/.","code":"@Manual{,   title = {surveytable: Formatted Survey Estimates},   author = {Alex Strashny},   year = {2023},   url = {https://cdcgov.github.io/surveytable/},   doi = {10.32614/CRAN.package.surveytable}, }"},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"survey-table-formatted-survey-estimates","dir":"","previous_headings":"","what":"Formatted Survey Estimates","title":"Formatted Survey Estimates","text":"surveytable R package conveniently tabulating estimates complex surveys. deal survey objects R (created survey::svydesign()), package . Works complex surveys (data systems involve survey design variables, like weights strata). Works unweighted data well. surveytable package provides short understandable commands generate tabulated, formatted, rounded survey estimates. surveytable, can tabulate estimated counts percentages, standard errors confidence intervals, estimate total population, tabulate survey subsets variable interactions, tabulate numeric variables, perform hypothesis tests, tabulate rates, modify survey variables, save output. Optionally, tabulation functions can identify low-precision estimates using National Center Health Statistics (NCHS) algorithms (algorithms). surveytable code called R Markdown notebook Quarto document, automatically generates HTML LaTeX tables, appropriate. package reduces number commands users need execute, especially helpful users new R programming.","code":""},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Formatted Survey Estimates","text":"Install CRAN: get development version GitHub:","code":"install.packages(\"surveytable\") install.packages(c(\"remotes\", \"git2r\")) remotes::install_github(\"CDCgov/surveytable\", upgrade = \"never\")"},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"documentation","dir":"","previous_headings":"","what":"Documentation","title":"Formatted Survey Estimates","text":"Find documentation surveytable : https://cdcgov.github.io/surveytable/","code":""},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"example","dir":"","previous_headings":"","what":"Example","title":"Formatted Survey Estimates","text":"basic example, get started. Load package: Specify survey wish analyze. surveytable comes survey called namcs2019sv, use examples. Survey info {NAMCS 2019 PUF} Specify variable analyze. NAMCS, AGER age category variable: Patient age recode {NAMCS 2019 PUF} table shows: Descriptive variable name Survey name Number observations Estimated count SE 95% CI Estimated percentage SE 95% CI Sample size Optionally, table can show whether low-precision estimates found","code":"library(surveytable) set_survey(namcs2019sv) #> * Mode: General. tab(\"AGER\")"},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"public-domain-standard-notice","dir":"","previous_headings":"","what":"Public Domain Standard Notice","title":"Formatted Survey Estimates","text":"repository constitutes work United States Government subject domestic copyright protection 17 USC § 105. repository public domain within United States, copyright related rights work worldwide waived CC0 1.0 Universal public domain dedication. contributions repository released CC0 dedication. submitting pull request agreeing comply waiver copyright interest.","code":""},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"license-standard-notice","dir":"","previous_headings":"","what":"License Standard Notice","title":"Formatted Survey Estimates","text":"repository utilizes code licensed terms Apache Software License therefore licensed ASL v2 later. source code repository free: can redistribute /modify terms Apache Software License version 2, (option) later version. source code repository distributed hope useful, WITHOUT WARRANTY; without even implied warranty MERCHANTABILITY FITNESS PARTICULAR PURPOSE. See Apache Software License details. received copy Apache Software License along program. , see https://www.apache.org/licenses/LICENSE-2.0.html source code forked open source projects inherit license.","code":""},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"privacy-standard-notice","dir":"","previous_headings":"","what":"Privacy Standard Notice","title":"Formatted Survey Estimates","text":"repository contains non-sensitive, publicly available data information. material community participation covered Disclaimer Code Conduct. information CDC’s privacy policy, please visit https://www.cdc.gov//privacy.html.","code":""},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"contributing-standard-notice","dir":"","previous_headings":"","what":"Contributing Standard Notice","title":"Formatted Survey Estimates","text":"Anyone encouraged contribute repository forking submitting pull request. (new GitHub, might start basic tutorial.) contributing project, grant world-wide, royalty-free, perpetual, irrevocable, non-exclusive, transferable license users terms Apache Software License v2 later. comments, messages, pull requests, submissions received CDC including GitHub page may subject applicable federal law, including limited Federal Records Act, may archived. Learn https://www.cdc.gov//privacy.html.","code":""},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"records-management-standard-notice","dir":"","previous_headings":"","what":"Records Management Standard Notice","title":"Formatted Survey Estimates","text":"repository source government records, copy increase collaboration collaborative potential. government records published CDC web site.","code":""},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"additional-standard-notices","dir":"","previous_headings":"","what":"Additional Standard Notices","title":"Formatted Survey Estimates","text":"Please refer CDC’s Template Repository information contributing repository, public domain notices disclaimers, code conduct.","code":""},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"Apache License","title":"Apache License","text":"Version 2.0, January 2004 ","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":"id_1-definitions","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"1. Definitions","title":"Apache License","text":"“License” shall mean terms conditions use, reproduction, distribution defined Sections 1 9 document. “Licensor” shall mean copyright owner entity authorized copyright owner granting License. “Legal Entity” shall mean union acting entity entities control, controlled , common control entity. purposes definition, “control” means () power, direct indirect, cause direction management entity, whether contract otherwise, (ii) ownership fifty percent (50%) outstanding shares, (iii) beneficial ownership entity. “” (“”) shall mean individual Legal Entity exercising permissions granted License. “Source” form shall mean preferred form making modifications, including limited software source code, documentation source, configuration files. “Object” form shall mean form resulting mechanical transformation translation Source form, including limited compiled object code, generated documentation, conversions media types. “Work” shall mean work authorship, whether Source Object form, made available License, indicated copyright notice included attached work (example provided Appendix ). “Derivative Works” shall mean work, whether Source Object form, based (derived ) Work editorial revisions, annotations, elaborations, modifications represent, whole, original work authorship. purposes License, Derivative Works shall include works remain separable , merely link (bind name) interfaces , Work Derivative Works thereof. “Contribution” shall mean work authorship, including original version Work modifications additions Work Derivative Works thereof, intentionally submitted Licensor inclusion Work copyright owner individual Legal Entity authorized submit behalf copyright owner. purposes definition, “submitted” means form electronic, verbal, written communication sent Licensor representatives, including limited communication electronic mailing lists, source code control systems, issue tracking systems managed , behalf , Licensor purpose discussing improving Work, excluding communication conspicuously marked otherwise designated writing copyright owner “Contribution.” “Contributor” shall mean Licensor individual Legal Entity behalf Contribution received Licensor subsequently incorporated within Work.","code":""},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":"id_2-grant-of-copyright-license","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"2. Grant of Copyright License","title":"Apache License","text":"Subject terms conditions License, Contributor hereby grants perpetual, worldwide, non-exclusive, -charge, royalty-free, irrevocable copyright license reproduce, prepare Derivative Works , publicly display, publicly perform, sublicense, distribute Work Derivative Works Source Object form.","code":""},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":"id_3-grant-of-patent-license","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"3. Grant of Patent License","title":"Apache License","text":"Subject terms conditions License, Contributor hereby grants perpetual, worldwide, non-exclusive, -charge, royalty-free, irrevocable (except stated section) patent license make, made, use, offer sell, sell, import, otherwise transfer Work, license applies patent claims licensable Contributor necessarily infringed Contribution(s) alone combination Contribution(s) Work Contribution(s) submitted. institute patent litigation entity (including cross-claim counterclaim lawsuit) alleging Work Contribution incorporated within Work constitutes direct contributory patent infringement, patent licenses granted License Work shall terminate date litigation filed.","code":""},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":"id_4-redistribution","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"4. Redistribution","title":"Apache License","text":"may reproduce distribute copies Work Derivative Works thereof medium, without modifications, Source Object form, provided meet following conditions: () must give recipients Work Derivative Works copy License; (b) must cause modified files carry prominent notices stating changed files; (c) must retain, Source form Derivative Works distribute, copyright, patent, trademark, attribution notices Source form Work, excluding notices pertain part Derivative Works; (d) Work includes “NOTICE” text file part distribution, Derivative Works distribute must include readable copy attribution notices contained within NOTICE file, excluding notices pertain part Derivative Works, least one following places: within NOTICE text file distributed part Derivative Works; within Source form documentation, provided along Derivative Works; , within display generated Derivative Works, wherever third-party notices normally appear. contents NOTICE file informational purposes modify License. may add attribution notices within Derivative Works distribute, alongside addendum NOTICE text Work, provided additional attribution notices construed modifying License. may add copyright statement modifications may provide additional different license terms conditions use, reproduction, distribution modifications, Derivative Works whole, provided use, reproduction, distribution Work otherwise complies conditions stated License.","code":""},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":"id_5-submission-of-contributions","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"5. Submission of Contributions","title":"Apache License","text":"Unless explicitly state otherwise, Contribution intentionally submitted inclusion Work Licensor shall terms conditions License, without additional terms conditions. Notwithstanding , nothing herein shall supersede modify terms separate license agreement may executed Licensor regarding Contributions.","code":""},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":"id_6-trademarks","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"6. Trademarks","title":"Apache License","text":"License grant permission use trade names, trademarks, service marks, product names Licensor, except required reasonable customary use describing origin Work reproducing content NOTICE file.","code":""},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":"id_7-disclaimer-of-warranty","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"7. Disclaimer of Warranty","title":"Apache License","text":"Unless required applicable law agreed writing, Licensor provides Work (Contributor provides Contributions) “” BASIS, WITHOUT WARRANTIES CONDITIONS KIND, either express implied, including, without limitation, warranties conditions TITLE, NON-INFRINGEMENT, MERCHANTABILITY, FITNESS PARTICULAR PURPOSE. solely responsible determining appropriateness using redistributing Work assume risks associated exercise permissions License.","code":""},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":"id_8-limitation-of-liability","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"8. Limitation of Liability","title":"Apache License","text":"event legal theory, whether tort (including negligence), contract, otherwise, unless required applicable law (deliberate grossly negligent acts) agreed writing, shall Contributor liable damages, including direct, indirect, special, incidental, consequential damages character arising result License use inability use Work (including limited damages loss goodwill, work stoppage, computer failure malfunction, commercial damages losses), even Contributor advised possibility damages.","code":""},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":"id_9-accepting-warranty-or-additional-liability","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"9. Accepting Warranty or Additional Liability","title":"Apache License","text":"redistributing Work Derivative Works thereof, may choose offer, charge fee , acceptance support, warranty, indemnity, liability obligations /rights consistent License. However, accepting obligations, may act behalf sole responsibility, behalf Contributor, agree indemnify, defend, hold Contributor harmless liability incurred , claims asserted , Contributor reason accepting warranty additional liability. END TERMS CONDITIONS","code":""},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":"appendix-how-to-apply-the-apache-license-to-your-work","dir":"","previous_headings":"","what":"APPENDIX: How to apply the Apache License to your work","title":"Apache License","text":"apply Apache License work, attach following boilerplate notice, fields enclosed brackets [] replaced identifying information. (Don’t include brackets!) text enclosed appropriate comment syntax file format. also recommend file class name description purpose included “printed page” copyright notice easier identification within third-party archives.","code":"Copyright [yyyy] [name of copyright owner]  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at    http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License."},{"path":"https://cdcgov.github.io/surveytable/reference/codebook.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a codebook for the survey — codebook","title":"Create a codebook for the survey — codebook","text":"Create codebook survey","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/codebook.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a codebook for the survey — codebook","text":"","code":"codebook(all = FALSE, csv = getOption(\"surveytable.csv\"))"},{"path":"https://cdcgov.github.io/surveytable/reference/codebook.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a codebook for the survey — codebook","text":"tabulate variables? csv name CSV file","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/codebook.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a codebook for the survey — codebook","text":"list tables.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/codebook.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a codebook for the survey — codebook","text":"","code":"set_survey(namcs2019sv) #> * Mode: General. #>                         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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  codebook() #> * Mode: General. #>                         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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  #>                                     Codebook {NAMCS 2019 PUF}                                      #> ┌──────────┬─────────────┬───────────────────────┬─────────┬─────────────┬───────────────────────┐ #> │ Item no. │ Variable    │ Description           │ Class   │ Missing (%) │ Values                │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │        1 │ CPSUM       │ Masked provider       │ numeric │           0 │ 100001 - 100398       │ #> │          │             │ marker                │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │        2 │ CSTRATM     │ Masked sampling       │ numeric │           0 │ 10119101 - 10419115   │ #> │          │             │ stratum from which    │         │             │                       │ #> │          │             │ provider was selected │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │        3 │ PATWT       │ Patient visit weight  │ numeric │           0 │ 7064.00718 -          │ #> │          │             │ used for national and │         │             │ 1120996.55599         │ #> │          │             │ subnational estimates │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │        4 │ MDDO        │ Type of doctor (MD or │ factor  │           0 │ M.D. - Doctor of      │ #> │          │             │ DO)                   │         │             │ Medicine, D.O. -      │ #> │          │             │                       │         │             │ Doctor of Osteopathy  │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │        5 │ SPECCAT     │ Type of specialty     │ factor  │           0 │ Primary care          │ #> │          │             │ (Primary, Medical,    │         │             │ specialty, Surgical   │ #> │          │             │ Surgical)             │         │             │ care specialty,       │ #> │          │             │                       │         │             │ Medical care          │ #> │          │             │                       │         │             │ specialty             │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │        6 │ MSA         │ Metropolitan          │ factor  │           0 │ MSA (Metropolitan     │ #> │          │             │ Statistical Area      │         │             │ Statistical Area),    │ #> │          │             │ Status of physician   │         │             │ Non-MSA               │ #> │          │             │ location              │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │        7 │ AGER        │ Patient age recode    │ factor  │           0 │ Under 15 years, 15-24 │ #> │          │             │                       │         │             │ years, 25-44 years,   │ #> │          │             │                       │         │             │ 45-64 years, 65-74    │ #> │          │             │                       │         │             │ years, 75 years and   │ #> │          │             │                       │         │             │ over                  │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │        8 │ SEX         │ Patient sex           │ factor  │           0 │ Female, Male          │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │        9 │ AGE         │ Patient age in years  │ numeric │           0 │ 0 - 94                │ #> │          │             │ (raw - use caution)   │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       10 │ NOPAY       │ Expected source of    │ factor  │           0 │ One or more           │ #> │          │             │ payment for visit: No │         │             │ categories marked, No │ #> │          │             │ answer to item        │         │             │ categories marked     │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       11 │ PAYPRIV     │ Expected source of    │ logical │           0 │                       │ #> │          │             │ payment for visit:    │         │             │                       │ #> │          │             │ Private insurance     │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       12 │ PAYMCARE    │ Expected source of    │ logical │           0 │                       │ #> │          │             │ payment for visit:    │         │             │                       │ #> │          │             │ Medicare              │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       13 │ PAYMCAID    │ Expected source of    │ logical │           0 │                       │ #> │          │             │ payment for visit:    │         │             │                       │ #> │          │             │ Medicaid or CHIP or   │         │             │                       │ #> │          │             │ other state-based     │         │             │                       │ #> │          │             │ program               │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       14 │ PAYWKCMP    │ Expected source of    │ logical │           0 │                       │ #> │          │             │ payment for visit:    │         │             │                       │ #> │          │             │ Workers Compensation  │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       15 │ PAYOTH      │ Expected source of    │ logical │           0 │                       │ #> │          │             │ payment for visit:    │         │             │                       │ #> │          │             │ Other                 │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       16 │ PAYDK       │ Expected source of    │ logical │           0 │                       │ #> │          │             │ payment for visit:    │         │             │                       │ #> │          │             │ Unknown               │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       17 │ PAYSELF     │ Expected source of    │ logical │           0 │                       │ #> │          │             │ payment for visit:    │         │             │                       │ #> │          │             │ Self-pay              │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       18 │ PAYNOCHG    │ Expected source of    │ logical │           0 │                       │ #> │          │             │ payment for visit: No │         │             │                       │ #> │          │             │ Charge/Charity        │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       19 │ PRIMCARE    │ Are you the patient's │ factor  │           0 │ Blank, Unknown, Yes,  │ #> │          │             │ primary care          │         │             │ No                    │ #> │          │             │ provider?             │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       20 │ REFER       │ Was patient referred  │ factor  │           0 │ Blank, Unknown, Not   │ #> │          │             │ for visit?            │         │             │ applicable, Yes, No   │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       21 │ SENBEFOR    │ Has this patient been │ factor  │           0 │ Yes, established      │ #> │          │             │ seen in your practice │         │             │ patient, No, new      │ #> │          │             │ before?               │         │             │ patient               │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       22 │ MAJOR       │ Major reason for this │ factor  │           0 │ Blank, New problem    │ #> │          │             │ visit                 │         │             │ (less than 3 mos.     │ #> │          │             │                       │         │             │ onset), Chronic       │ #> │          │             │                       │         │             │ problem, routine,     │ #> │          │             │                       │         │             │ Chronic problem,      │ #> │          │             │                       │         │             │ flare-up,             │ #> │          │             │                       │         │             │ Pre-surgery,          │ #> │          │             │                       │         │             │ Post-surgery,         │ #> │          │             │                       │         │             │ Preventive care       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       23 │ NUMMED      │ Number of medications │ numeric │           0 │ 0 - 30                │ #> │          │             │ coded                 │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       24 │ ANYIMAGE    │ Any imaging           │ logical │           0 │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       25 │ BONEDENS    │ Bone mineral density  │ logical │           0 │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       26 │ CATSCAN     │ CT Scan               │ logical │           0 │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       27 │ ECHOCARD    │ Echocardiogram        │ logical │           0 │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       28 │ OTHULTRA    │ Ultrasound            │ logical │           0 │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       29 │ MAMMO       │ Mammography           │ logical │           0 │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       30 │ MRI         │ MRI                   │ logical │           0 │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       31 │ XRAY        │ X-ray                 │ logical │           0 │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       32 │ OTHIMAGE    │ Other imaging         │ logical │           0 │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       33 │ SPECCAT.bad │ Type of specialty     │ factor  │          20 │ Primary care          │ #> │          │             │ (BAD - do not use)    │         │             │ specialty, Surgical   │ #> │          │             │                       │         │             │ care specialty,       │ #> │          │             │                       │         │             │ Medical care          │ #> │          │             │                       │         │             │ specialty             │ #> └──────────┴─────────────┴───────────────────────┴─────────┴─────────────┴───────────────────────┘ #>"},{"path":"https://cdcgov.github.io/surveytable/reference/namcs2019sv.html","id":null,"dir":"Reference","previous_headings":"","what":"Selected variables from the National Ambulatory Medical Care Survey (NAMCS) 2019 Public Use File (PUF) — namcs2019sv","title":"Selected variables from the National Ambulatory Medical Care Survey (NAMCS) 2019 Public Use File (PUF) — namcs2019sv","text":"Selected variables data system visits office-based physicians. Note unit observation visits, patients - distinction important since single patient can make multiple visits.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/namcs2019sv.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Selected variables from the National Ambulatory Medical Care Survey (NAMCS) 2019 Public Use File (PUF) — namcs2019sv","text":"","code":"namcs2019sv  namcs2019sv_df"},{"path":"https://cdcgov.github.io/surveytable/reference/namcs2019sv.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Selected variables from the National Ambulatory Medical Care Survey (NAMCS) 2019 Public Use File (PUF) — namcs2019sv","text":"object class survey.design2 (inherits survey.design) 8250 rows 33 columns. object class data.frame 8250 rows 33 columns.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/namcs2019sv.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Selected variables from the National Ambulatory Medical Care Survey (NAMCS) 2019 Public Use File (PUF) — namcs2019sv","text":"SAS data: https://ftp.cdc.gov/pub/Health_Statistics/NCHS/Dataset_Documentation/NAMCS/sas/namcs2019_sas.zip Survey design variables: https://ftp.cdc.gov/pub/Health_Statistics/NCHS/Dataset_Documentation/NAMCS/sas/readme2019-sas.txt SAS formats: https://ftp.cdc.gov/pub/Health_Statistics/NCHS/Dataset_Documentation/NAMCS/sas/nam19for.txt Documentation: https://ftp.cdc.gov/pub/Health_Statistics/NCHS/Dataset_Documentation/NAMCS/doc2019-508.pdf National Summary Tables: https://www.cdc.gov/nchs/data/ahcd/namcs_summary/2019-namcs-web-tables-508.pdf","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/namcs2019sv.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Selected variables from the National Ambulatory Medical Care Survey (NAMCS) 2019 Public Use File (PUF) — namcs2019sv","text":"namcs2019sv_df data frame. namcs2019sv survey object created namcs2019sv_df using survey::svydesign().","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/print.surveytable_table.html","id":null,"dir":"Reference","previous_headings":"","what":"Print surveytable tables — print.surveytable_table","title":"Print surveytable tables — print.surveytable_table","text":"Print surveytable tables","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/print.surveytable_table.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Print surveytable tables — print.surveytable_table","text":"","code":"# S3 method for surveytable_table print(x, .output = NULL, ...)  # S3 method for surveytable_list print(x, .output = NULL, ...)"},{"path":"https://cdcgov.github.io/surveytable/reference/print.surveytable_table.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Print surveytable tables — print.surveytable_table","text":"x object class surveytable_table surveytable_list. .output output type. NULL = auto-detect. ... ignored","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/print.surveytable_table.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Print surveytable tables — print.surveytable_table","text":"x invisibly.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/print.surveytable_table.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Print surveytable tables — print.surveytable_table","text":"","code":"set_survey(namcs2019sv) #> * Mode: General. #>                         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.                                                                                                  #>"},{"path":"https://cdcgov.github.io/surveytable/reference/rccsu2018.html","id":null,"dir":"Reference","previous_headings":"","what":"National Study of Long-Term Care Providers (NSLTCP) Residential Care Community (RCC) Services User (SU) 2018 Public Use File (PUF) — rccsu2018","title":"National Study of Long-Term Care Providers (NSLTCP) Residential Care Community (RCC) Services User (SU) 2018 Public Use File (PUF) — rccsu2018","text":"data system RCC residents.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/rccsu2018.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"National Study of Long-Term Care Providers (NSLTCP) Residential Care Community (RCC) Services User (SU) 2018 Public Use File (PUF) — rccsu2018","text":"","code":"rccsu2018"},{"path":"https://cdcgov.github.io/surveytable/reference/rccsu2018.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"National Study of Long-Term Care Providers (NSLTCP) Residential Care Community (RCC) Services User (SU) 2018 Public Use File (PUF) — rccsu2018","text":"object class survey.design2 (inherits survey.design) 904 rows 81 columns.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/rccsu2018.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"National Study of Long-Term Care Providers (NSLTCP) Residential Care Community (RCC) Services User (SU) 2018 Public Use File (PUF) — rccsu2018","text":"SAS data: https://ftp.cdc.gov/pub/Health_Statistics/NCHS/Datasets/NPALS/final2018rcc_su_puf.sas7bdat Documentation: https://www.cdc.gov/nchs/npals/RCCresident-readme03152021vr.pdf Codebook: https://www.cdc.gov/nchs/data/npals/final2018rcc_su_puf_codebook.pdf","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/set_count_1k.html","id":null,"dir":"Reference","previous_headings":"","what":"Rounding counts — set_count_1k","title":"Rounding counts — set_count_1k","text":"Determines counts rounded.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/set_count_1k.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Rounding counts — set_count_1k","text":"","code":"set_count_1k()  set_count_int()"},{"path":"https://cdcgov.github.io/surveytable/reference/set_count_1k.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Rounding counts — set_count_1k","text":"(Nothing.)","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/set_count_1k.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Rounding counts — set_count_1k","text":"set_count_1k(): round counts nearest 1,000. set_count_int(): round counts nearest integer.","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/set_count_1k.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Rounding counts — set_count_1k","text":"","code":"set_survey(namcs2019sv) #> * Mode: General. #>                         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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  set_count_int() #> * Rounding counts to the nearest integer. #> * ?set_count_int for other options. total() #>                        Total {NAMCS 2019 PUF}                        #> ┌───────┬───────────────┬────────────┬─────────────┬───────────────┐ #> │     n │        Number │         SE │          LL │            UL │ #> ├───────┼───────────────┼────────────┼─────────────┼───────────────┤ #> │ 8,250 │ 1,036,484,356 │ 48,836,217 │ 945,013,590 │ 1,136,808,860 │ #> └───────┴───────────────┴────────────┴─────────────┴───────────────┘ #>   N = 8250.                                                          #>   set_count_1k() #> * Rounding counts to the nearest 1,000. #> * ?set_count_1k for other options. total() #>                   Total {NAMCS 2019 PUF}                   #> ┌───────┬──────────────┬──────────┬──────────┬───────────┐ #> │     n │ Number (000) │ SE (000) │ LL (000) │  UL (000) │ #> ├───────┼──────────────┼──────────┼──────────┼───────────┤ #> │ 8,250 │    1,036,484 │   48,836 │  945,014 │ 1,136,809 │ #> └───────┴──────────────┴──────────┴──────────┴───────────┘ #>   N = 8250.                                                #>"},{"path":"https://cdcgov.github.io/surveytable/reference/set_output.html","id":null,"dir":"Reference","previous_headings":"","what":"Set output defaults — set_output","title":"Set output defaults — set_output","text":"show_output() shows current defaults.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/set_output.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set output defaults — set_output","text":"","code":"set_output(drop_na = NULL, max_levels = NULL, csv = NULL)  show_output()"},{"path":"https://cdcgov.github.io/surveytable/reference/set_output.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set output defaults — set_output","text":"drop_na drop missing values (NA)? Categorical variables . max_levels categorical variable can many levels. Used avoid printing huge tables. csv name CSV file \"\" turn CSV output","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/set_output.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set output defaults — set_output","text":"(Nothing.)","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/set_output.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set output defaults — set_output","text":"","code":"tmp_file = tempfile(fileext = \".csv\") suppressMessages( set_output(csv = tmp_file) ) tab(\"AGER\") #>                                 Patient age recode {NAMCS 2019 PUF}                                  #> ┌─────────────┬───────┬─────────────┬──────────┬──────────┬──────────┬─────────┬─────┬──────┬──────┐ #> │ Level       │     n │      Number │ SE (000) │ LL (000) │ UL (000) │ Percent │  SE │   LL │   UL │ #> │             │       │       (000) │          │          │          │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼──────────┼──────────┼──────────┼─────────┼─────┼──────┼──────┤ #> │ 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_output(csv = \"\") # Turn off CSV output #> * Turning off CSV output. #> * ?set_output for other options."},{"path":"https://cdcgov.github.io/surveytable/reference/set_survey.html","id":null,"dir":"Reference","previous_headings":"","what":"Specify the survey to analyze — set_survey","title":"Specify the survey to analyze — set_survey","text":"must specify survey functions, tab(), work. convert data.frame survey object, see survey::svydesign() survey::svrepdesign().","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/set_survey.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Specify the survey to analyze — set_survey","text":"","code":"set_survey(design, mode = \"default\", csv = getOption(\"surveytable.csv\"))  set_mode(mode = \"default\")"},{"path":"https://cdcgov.github.io/surveytable/reference/set_survey.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Specify the survey to analyze — set_survey","text":"design either survey object (created survey::svydesign() survey::svrepdesign()); , unweighted survey, data.frame. mode set certain options. See . csv name CSV file","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/set_survey.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Specify the survey to analyze — set_survey","text":"set_survey: info survey. set_mode: nothing.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/set_survey.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Specify the survey to analyze — set_survey","text":"Optionally, survey can attribute called label, long name survey. Optionally, variable survey can attribute called label, variable's long name. sure mode , leave \"default\". mode : \"general\" \"default\": Round counts nearest integer -- see set_count_int(). look low-precision estimates. Percentage CI's: use standard Korn-Graubard CI's. \"nchs\": Round counts nearest 1,000 -- see set_count_1k(). Identify low-precision estimates. Percentage CI's: adjust Korn-Graubard CI's number degrees freedom, matching SUDAAN calculation.","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/set_survey.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Specify the survey to analyze — set_survey","text":"","code":"set_survey(namcs2019sv) #> * Mode: General. #>                         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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  set_mode(\"general\") #> * Mode: General."},{"path":"https://cdcgov.github.io/surveytable/reference/show_options.html","id":null,"dir":"Reference","previous_headings":"","what":"Show package options — show_options","title":"Show package options — show_options","text":"See surveytable-options discussion options.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/show_options.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Show package options — show_options","text":"","code":"show_options(sw = \"surveytable\")"},{"path":"https://cdcgov.github.io/surveytable/reference/show_options.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Show package options — show_options","text":"sw starting characters","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/show_options.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Show package options — show_options","text":"List options values.","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/show_options.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Show package options — show_options","text":"","code":"show_options() #> $surveytable.adjust_svyciprop #> [1] FALSE #>  #> $surveytable.adjust_svyciprop.df_method #> [1] \"NHIS\" #>  #> $surveytable.csv #> [1] \"\" #>  #> $surveytable.drop_na #> [1] FALSE #>  #> $surveytable.find_lpe #> [1] FALSE #>  #> $surveytable.lpe_counts #> [1] \".lpe_counts\" #>  #> $surveytable.lpe_n #> [1] \".lpe_n\" #>  #> $surveytable.lpe_percents #> [1] \".lpe_percents\" #>  #> $surveytable.max_levels #> [1] 20 #>  #> $surveytable.names_count #> [1] \"n\"      \"Number\" \"SE\"     \"LL\"     \"UL\"     #>  #> $surveytable.names_prct #> [1] \"Percent\" \"SE\"      \"LL\"      \"UL\"      #>  #> $surveytable.p.adjust_method #> [1] \"bonferroni\" #>  #> $surveytable.rate_per #> [1] 100 #>  #> $surveytable.survey_label #> [1] \"NAMCS 2019 PUF\" #>  #> $surveytable.svychisq_statistic #> [1] \"F\" #>  #> $surveytable.tx_count #> [1] \".tx_count_int\" #>  #> $surveytable.tx_numeric #> [1] \".tx_numeric\" #>  #> $surveytable.tx_prct #> [1] \".tx_prct\" #>  #> $surveytable.tx_rate #> [1] \".tx_rate\" #>"},{"path":"https://cdcgov.github.io/surveytable/reference/surveytable-options.html","id":null,"dir":"Reference","previous_headings":"","what":"Package options — surveytable-options","title":"Package options — surveytable-options","text":"Run show_options() see available options. description notable options.","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/surveytable-options.html","id":"low-precision-estimates-","dir":"Reference","previous_headings":"","what":"Low-precision estimates.","title":"Package options — surveytable-options","text":"Optionally, tabulation functions can identify low-precision estimates. turn functionality, either set surveytable.find_lpe option TRUE, call set_survey() set_mode() argument mode = \"NCHS\". default, low-precision estimates identified using National Center Health Statistics (NCHS) algorithms. However, can changed, described . description options related identification low-precision estimates. surveytable.find_lpe: tabulation functions look low-precision estimates? can change directly options() mode argument set_survey() set_mode(). surveytable.lpe_n, surveytable.lpe_counts, surveytable.lpe_percents: names 3 functions. argument surveytable.lpe_n vector number observations level variable. argument surveytable.lpe_counts data frame count-related estimates. Specifically, data frame following variables: x: point estimates counts s: SE ll, ul: CI samp.size: effective sample size counts: actual sample size degf: degrees freedom argument surveytable.lpe_percents data frame percent-related estimates. Specifically, data frame following variables: Proportion: point estimates proportions (0 1) SE: SE LL, UL: CI n numerator: number observations variable TRUE n denominator: total number observations functions must return list following elements: id: name algorithm used, \"NCHS presentation standards\" flags: vector. level variable, short codes indicating presence low-precision estimates. .flag: vector short codes present flags. descriptions: named vector. names must short codes, values longer descriptions. example, variable 3 levels, flags might c(\"\", \"A1 A2\", \"\"). indicates first third level, nothing found, whereas second level, two different things found, indicated short codes A1 A2. case, .flag = c(\"A1\", \"A2\"), descriptions = c(A1 = \"A1: something\", A2 = \"A2: something else\").","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/surveytable-options.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Package options — surveytable-options","text":"Maintainer: Alex Strashny AStrashny@cdc.gov (ORCID)","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/surveytable-package.html","id":null,"dir":"Reference","previous_headings":"","what":"surveytable: Formatted Survey Estimates — surveytable-package","title":"surveytable: Formatted Survey Estimates — surveytable-package","text":"Short understandable commands generate tabulated, formatted, rounded survey estimates. Mostly wrapper 'survey' package (Lumley (2004) doi:10.18637/jss.v009.i08  https://CRAN.R-project.org/package=survey) identifies low-precision estimates using National Center Health Statistics (NCHS) presentation standards (Parker et al. (2017) https://www.cdc.gov/nchs/data/series/sr_02/sr02_175.pdf, Parker et al. (2023) doi:10.15620/cdc:124368 ).","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/surveytable-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"surveytable: Formatted Survey Estimates — surveytable-package","text":"Maintainer: Alex Strashny AStrashny@cdc.gov (ORCID)","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/survey_subset.html","id":null,"dir":"Reference","previous_headings":"","what":"Subset a survey, while preserving variable labels — survey_subset","title":"Subset a survey, while preserving variable labels — survey_subset","text":"Subset survey, preserving variable labels","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/survey_subset.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Subset a survey, while preserving variable labels — survey_subset","text":"","code":"survey_subset(design, subset, label)"},{"path":"https://cdcgov.github.io/surveytable/reference/survey_subset.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Subset a survey, while preserving variable labels — survey_subset","text":"design survey object subset expression specifying sub-population label survey label newly created survey object","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/survey_subset.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Subset a survey, while preserving variable labels — survey_subset","text":"new survey object","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/survey_subset.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Subset a survey, while preserving variable labels — survey_subset","text":"","code":"children = survey_subset(namcs2019sv, AGE < 18, \"Children < 18\") set_survey(children) #> * Mode: General. #>                          Survey info {Children < 18}                          #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐ #> │ Variables │ Observations │ Design                                         │ #> ├───────────┼──────────────┼────────────────────────────────────────────────┤ #> │        33 │        1,066 │ Stratified 1 - level Cluster Sampling design   │ #> │           │              │ (with replacement)                             │ #> │           │              │ With (139) clusters.                           │ #> │           │              │ survey_subset(namcs2019sv, AGE < 18, \"Children │ #> │           │              │ < 18\")                                         │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  tab(\"AGER\") #>                                    Patient age recode {Children < 18}                                     #> ┌─────────────┬─────┬─────────────┬────────────┬────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ 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 │    86.1 │ 1.6 │ 82.5 │ 89.2 │ #> │ years       │     │             │            │            │             │         │     │      │      │ #> ├─────────────┼─────┼─────────────┼────────────┼────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 15-24 years │ 179 │  19,003,548 │  2,871,580 │ 14,050,905 │  25,701,891 │    13.9 │ 1.6 │ 10.8 │ 17.5 │ #> └─────────────┴─────┴─────────────┴────────────┴────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 1066.                                                                                               #>"},{"path":"https://cdcgov.github.io/surveytable/reference/svyciprop_adjusted.html","id":null,"dir":"Reference","previous_headings":"","what":"Confidence intervals for proportions, adjusted for degrees of freedom — svyciprop_adjusted","title":"Confidence intervals for proportions, adjusted for degrees of freedom — svyciprop_adjusted","text":"version survey::svyciprop() adjusts degrees freedom method = \"beta\".","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/svyciprop_adjusted.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Confidence intervals for proportions, adjusted for degrees of freedom — svyciprop_adjusted","text":"","code":"svyciprop_adjusted(   formula,   design,   method = c(\"logit\", \"likelihood\", \"asin\", \"beta\", \"mean\", \"xlogit\"),   level = 0.95,   df_method,   ... )"},{"path":"https://cdcgov.github.io/surveytable/reference/svyciprop_adjusted.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Confidence intervals for proportions, adjusted for degrees of freedom — svyciprop_adjusted","text":"formula see survey::svyciprop(). design see survey::svyciprop(). method see survey::svyciprop(). level see survey::svyciprop(). df_method df calculated: \"default\" \"NHIS\". ... see survey::svyciprop().","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/svyciprop_adjusted.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Confidence intervals for proportions, adjusted for degrees of freedom — svyciprop_adjusted","text":"point estimate proportion, confidence interval attribute.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/svyciprop_adjusted.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Confidence intervals for proportions, adjusted for degrees of freedom — svyciprop_adjusted","text":"Written Makram Talih 2019. df_method: \"default\", df = degf(design); \"NHIS\", df = nrow(design) - 1. use function tabulations, call set_survey() set_mode() mode = \"NCHS\" argument, type: options(surveytable.adjust_svyciprop = TRUE).","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/svyciprop_adjusted.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Confidence intervals for proportions, adjusted for degrees of freedom — svyciprop_adjusted","text":"","code":"set_survey(namcs2019sv) #> * Mode: General. #>                         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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  set_mode(\"NCHS\") #> * Mode: NCHS. tab(\"AGER\") #>                                 Patient age recode {NAMCS 2019 PUF}                                  #> ┌─────────────┬───────┬─────────────┬──────────┬──────────┬──────────┬─────────┬─────┬──────┬──────┐ #> │ Level       │     n │      Number │ SE (000) │ LL (000) │ UL (000) │ Percent │  SE │   LL │   UL │ #> │             │       │       (000) │          │          │          │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼──────────┼──────────┼──────────┼─────────┼─────┼──────┼──────┤ #> │ 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. Checked NCHS presentation standards. Nothing to report.                                  #>  set_mode(\"general\") #> * Mode: General."},{"path":"https://cdcgov.github.io/surveytable/reference/tab.html","id":null,"dir":"Reference","previous_headings":"","what":"Tabulate variables — tab","title":"Tabulate variables — tab","text":"Tabulate categorical (factor), logical, numeric variables.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/tab.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tabulate variables — tab","text":"","code":"tab(   ...,   test = FALSE,   alpha = 0.05,   p_adjust = FALSE,   drop_na = getOption(\"surveytable.drop_na\"),   max_levels = getOption(\"surveytable.max_levels\"),   csv = getOption(\"surveytable.csv\") )"},{"path":"https://cdcgov.github.io/surveytable/reference/tab.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tabulate variables — tab","text":"... names variables (quotes) test perform hypothesis tests? alpha significance level tests p_adjust adjust p-values multiple comparisons? drop_na drop missing values (NA)? Categorical variables . max_levels categorical variable can many levels. Used avoid printing huge tables. csv name CSV file","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/tab.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tabulate variables — tab","text":"list tables single table.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/tab.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tabulate variables — tab","text":"categorical logical variables, presents estimated counts, standard errors (SEs) confidence intervals (CIs), percentages, SEs CIs. Checks presentation guidelines counts percentages flags estimates , according guidelines, suppressed, footnoted, reviewed analyst. numeric variables, presents percentage observations known values, mean known values, standard error mean (SEM), standard deviation (SD). CIs calculated 95% confidence level. CIs count estimates log Student's t CIs, adaptations complex surveys. CIs percentage estimates Korn Graubard CIs.","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/tab.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tabulate variables — tab","text":"","code":"set_survey(namcs2019sv) #> * Mode: General. #>                         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.                                                                                                  #>  tab(\"MDDO\", \"SPECCAT\", \"MSA\") #>                                  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.                                                                                                  #>   # Numeric variables tab(\"NUMMED\") #> Number of medications coded {NAMCS 2019 PUF} #> ┌─────────┬──────┬───────┬──────┐ #> │ % known │ Mean │   SEM │   SD │ #> ├─────────┼──────┼───────┼──────┤ #> │     100 │ 3.46 │ 0.268 │ 4.43 │ #> └─────────┴──────┴───────┴──────┘ #>   # Hypothesis testing with categorical variables tab(\"AGER\", test = TRUE) #>                                     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.                                                                                                  #>  #> Comparison of all possible pairs of Patient age recode {NAMCS 2019 PUF} #> ┌────────────────┬───────────────────┬─────────┬──────┐ #> │ Level 1        │ Level 2           │ p-value │ Flag │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ Under 15 years │ 15-24 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ Under 15 years │ 25-44 years       │   0.012 │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ Under 15 years │ 45-64 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ Under 15 years │ 65-74 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ Under 15 years │ 75 years and over │   0.022 │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 15-24 years    │ 25-44 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 15-24 years    │ 45-64 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 15-24 years    │ 65-74 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 15-24 years    │ 75 years and over │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 25-44 years    │ 45-64 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 25-44 years    │ 65-74 years       │   0.065 │      │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 25-44 years    │ 75 years and over │   0.878 │      │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 45-64 years    │ 65-74 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 45-64 years    │ 75 years and over │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 65-74 years    │ 75 years and over │   0.019 │ *    │ #> └────────────────┴───────────────────┴─────────┴──────┘ #>   Design-based t-test. *: p <= 0.05                     #>"},{"path":"https://cdcgov.github.io/surveytable/reference/tab_rate.html","id":null,"dir":"Reference","previous_headings":"","what":"Calculate rates — tab_rate","title":"Calculate rates — tab_rate","text":"Calculate rates categorical (factor) logical variables.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/tab_rate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Calculate rates — tab_rate","text":"","code":"tab_rate(   vr,   pop,   per = getOption(\"surveytable.rate_per\"),   drop_na = getOption(\"surveytable.drop_na\"),   max_levels = getOption(\"surveytable.max_levels\"),   csv = getOption(\"surveytable.csv\") )"},{"path":"https://cdcgov.github.io/surveytable/reference/tab_rate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Calculate rates — tab_rate","text":"vr variable tabulate pop either single number data.frame columns named Level Population. Level must exactly match levels vr. Population population level vr. per calculate rate per many items population drop_na drop missing values (NA)? max_levels categorical variable can many levels. Used avoid printing huge tables. csv name CSV file","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/tab_rate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Calculate rates — tab_rate","text":"list tables single table.","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/tab_rate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Calculate rates — tab_rate","text":"","code":"set_survey(namcs2019sv) #> * Mode: General. #>                         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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  # pop is a data frame tab_rate(\"MSA\", uspop2019$MSA) #> Metropolitan Statistical Area Status of physician location (rate per 100 population) {NAMCS 2019 PUF} #> ┌───────────────────────┬───────┬───────┬──────┬───────┬───────┐ #> │ Level                 │     n │  Rate │   SE │    LL │    UL │ #> ├───────────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ MSA (Metropolitan     │ 7,496 │ 351.2 │ 18.2 │ 317.2 │ 388.8 │ #> │ Statistical Area)     │       │       │      │       │       │ #> ├───────────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ Non-MSA               │   754 │ 136.7 │ 38.2 │  78.9 │ 236.8 │ #> └───────────────────────┴───────┴───────┴──────┴───────┴───────┘ #>   N = 8250.                                                      #>   # pop is a single number tab_rate(\"MDDO\", uspop2019$total) #> * Rate based on the entire population. #> Type of doctor (MD or DO) (rate per 100 population) {NAMCS 2019 PUF} #> ┌───────────────────────┬───────┬───────┬────┬───────┬───────┐ #> │ Level                 │     n │  Rate │ SE │    LL │    UL │ #> ├───────────────────────┼───────┼───────┼────┼───────┼───────┤ #> │ M.D. - Doctor of      │ 7,498 │ 303.3 │ 15 │ 275.3 │ 334.1 │ #> │ Medicine              │       │       │    │       │       │ #> ├───────────────────────┼───────┼───────┼────┼───────┼───────┤ #> │ D.O. - Doctor of      │   752 │  17.4 │  2 │  13.8 │  21.9 │ #> │ Osteopathy            │       │       │    │       │       │ #> └───────────────────────┴───────┴───────┴────┴───────┴───────┘ #>   N = 8250.                                                    #>"},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset.html","id":null,"dir":"Reference","previous_headings":"","what":"Tabulate subsets or interactions — tab_cross","title":"Tabulate subsets or interactions — tab_cross","text":"Create subsets survey using one variable, tabulate another variable within subsets. Interact two variables tabulate.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tabulate subsets or interactions — tab_cross","text":"","code":"tab_cross(   vr,   vrby,   max_levels = getOption(\"surveytable.max_levels\"),   csv = getOption(\"surveytable.csv\") )  tab_subset(   vr,   vrby,   lvls = c(),   test = FALSE,   alpha = 0.05,   p_adjust = FALSE,   drop_na = getOption(\"surveytable.drop_na\"),   max_levels = getOption(\"surveytable.max_levels\"),   csv = getOption(\"surveytable.csv\") )"},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tabulate subsets or interactions — tab_cross","text":"vr variable tabulate vrby use variable subset survey max_levels categorical variable can many levels. Used avoid printing huge tables. csv name CSV file lvls (optional) show levels vrby test perform hypothesis tests? alpha significance level tests p_adjust adjust p-values multiple comparisons? drop_na drop missing values (NA)? Categorical variables .","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tabulate subsets or interactions — tab_cross","text":"list tables single table.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tabulate subsets or interactions — tab_cross","text":"tab_subset creates subsets using levels vrby, tabulates vr subset. Optionally, use lvls levels vrby. vr can categorical (factor), logical, numeric. tab_cross crosses interacts vr vrby tabulates new variable. Tables created using tab_subset tab_cross counts different percentages. tab_subset, percentages within subset add 100%. tab_cross, percentages across entire population add 100%. Also see var_cross(). test = TRUE performs test association two variables. Also performs t-tests possible pairs levels vr vrby.","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tabulate subsets or interactions — tab_cross","text":"","code":"set_survey(namcs2019sv) #> * Mode: General. #>                         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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>   # For each SEX, tabulate AGER tab_subset(\"AGER\", \"SEX\") #>                          Patient age recode (Patient sex = Female) {NAMCS 2019 PUF}                          #> ┌─────────────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level       │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Under 15    │   434 │  59,957,823 │  7,205,594 │  47,318,228 │  75,973,693 │     9.9 │ 1.2 │  7.6 │ 12.6 │ #> │ years       │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 15-24 years │   346 │  41,128,003 │  4,532,466 │  33,065,609 │  51,156,253 │     6.8 │ 0.7 │  5.4 │  8.4 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 25-44 years │   923 │ 113,708,461 │ 11,461,189 │  93,256,445 │ 138,645,797 │    18.8 │ 1.6 │ 15.8 │ 22.1 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 45-64 years │ 1,253 │ 175,978,133 │ 16,008,541 │ 147,152,826 │ 210,449,940 │    29.1 │ 1.7 │ 25.7 │ 32.6 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 65-74 years │   891 │ 120,099,493 │ 11,066,146 │ 100,171,315 │ 143,992,203 │    19.8 │ 1.5 │ 17   │ 22.9 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 75 years    │   762 │  94,173,155 │ 11,085,372 │  74,682,310 │ 118,750,789 │    15.6 │ 1.5 │ 12.8 │ 18.7 │ #> │ and over    │       │             │            │             │             │         │     │      │      │ #> └─────────────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 4609.                                                                                                  #>  #>                           Patient age recode (Patient sex = Male) {NAMCS 2019 PUF}                           #> ┌─────────────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level       │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Under 15    │   453 │  57,958,950 │  7,727,594 │  44,569,688 │  75,370,504 │    13.4 │ 1.7 │ 10.3 │ 17.1 │ #> │ years       │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 15-24 years │   196 │  23,727,695 │  4,343,932 │  16,457,071 │  34,210,431 │     5.5 │ 0.8 │  4   │  7.4 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 25-44 years │   512 │  56,562,143 │  7,276,983 │  43,860,836 │  72,941,520 │    13.1 │ 1.3 │ 10.7 │ 15.8 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 45-64 years │ 1,030 │ 133,527,822 │ 12,956,239 │ 110,319,199 │ 161,619,006 │    30.9 │ 1.6 │ 27.8 │ 34.3 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 65-74 years │   770 │  86,766,489 │  6,766,876 │  74,409,284 │ 101,175,865 │    20.1 │ 1.5 │ 17.3 │ 23.1 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 75 years    │   680 │  72,896,189 │  6,660,855 │  60,871,965 │  87,295,593 │    16.9 │ 1.5 │ 14   │ 20.2 │ #> │ and over    │       │             │            │             │             │         │     │      │      │ #> └─────────────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 3641.                                                                                                  #>   # Same counts as tab_subset(), but different percentages. tab_cross(\"AGER\", \"SEX\") #>                            (Patient age recode) x (Patient sex) {NAMCS 2019 PUF}                             #> ┌─────────────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level       │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Under 15    │   434 │  59,957,823 │  7,205,594 │  47,318,228 │  75,973,693 │     5.8 │ 0.7 │  4.5 │  7.3 │ #> │ years:      │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 15-24       │   346 │  41,128,003 │  4,532,466 │  33,065,609 │  51,156,253 │     4   │ 0.4 │  3.2 │  4.9 │ #> │ years:      │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 25-44       │   923 │ 113,708,461 │ 11,461,189 │  93,256,445 │ 138,645,797 │    11   │ 1   │  9   │ 13.2 │ #> │ years:      │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 45-64       │ 1,253 │ 175,978,133 │ 16,008,541 │ 147,152,826 │ 210,449,940 │    17   │ 1.1 │ 14.8 │ 19.3 │ #> │ years:      │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 65-74       │   891 │ 120,099,493 │ 11,066,146 │ 100,171,315 │ 143,992,203 │    11.6 │ 1   │  9.7 │ 13.7 │ #> │ years:      │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 75 years    │   762 │  94,173,155 │ 11,085,372 │  74,682,310 │ 118,750,789 │     9.1 │ 0.9 │  7.3 │ 11.1 │ #> │ and over:   │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Under 15    │   453 │  57,958,950 │  7,727,594 │  44,569,688 │  75,370,504 │     5.6 │ 0.7 │  4.3 │  7.2 │ #> │ years: Male │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 15-24       │   196 │  23,727,695 │  4,343,932 │  16,457,071 │  34,210,431 │     2.3 │ 0.4 │  1.6 │  3.2 │ #> │ years: Male │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 25-44       │   512 │  56,562,143 │  7,276,983 │  43,860,836 │  72,941,520 │     5.5 │ 0.6 │  4.3 │  6.8 │ #> │ years: Male │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 45-64       │ 1,030 │ 133,527,822 │ 12,956,239 │ 110,319,199 │ 161,619,006 │    12.9 │ 1   │ 10.9 │ 15.1 │ #> │ years: Male │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 65-74       │   770 │  86,766,489 │  6,766,876 │  74,409,284 │ 101,175,865 │     8.4 │ 0.6 │  7.2 │  9.7 │ #> │ years: Male │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 75 years    │   680 │  72,896,189 │  6,660,855 │  60,871,965 │  87,295,593 │     7   │ 0.6 │  5.9 │  8.3 │ #> │ and over:   │       │             │            │             │             │         │     │      │      │ #> │ Male        │       │             │            │             │             │         │     │      │      │ #> └─────────────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                                  #>   # Numeric variables tab_subset(\"NUMMED\", \"AGER\") #> Number of medications coded (for different levels of Patient age recode) {NAMCS 2019 PUF} #> ┌───────────────────┬─────────┬──────┬───────┬──────┐ #> │ Level             │ % known │ Mean │   SEM │   SD │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ Under 15 years    │     100 │ 1.58 │ 0.168 │ 1.75 │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ 15-24 years       │     100 │ 1.64 │ 0.112 │ 1.7  │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ 25-44 years       │     100 │ 2.15 │ 0.225 │ 2.74 │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ 45-64 years       │     100 │ 3.49 │ 0.303 │ 4.49 │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ 65-74 years       │     100 │ 4.44 │ 0.431 │ 5.03 │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ 75 years and over │     100 │ 5.53 │ 0.494 │ 5.59 │ #> └───────────────────┴─────────┴──────┴───────┴──────┘ #>   # Hypothesis testing tab_subset(\"NUMMED\", \"AGER\", test = TRUE) #> Number of medications coded (for different levels of Patient age recode) {NAMCS 2019 PUF} #> ┌───────────────────┬─────────┬──────┬───────┬──────┐ #> │ Level             │ % known │ Mean │   SEM │   SD │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ Under 15 years    │     100 │ 1.58 │ 0.168 │ 1.75 │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ 15-24 years       │     100 │ 1.64 │ 0.112 │ 1.7  │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ 25-44 years       │     100 │ 2.15 │ 0.225 │ 2.74 │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ 45-64 years       │     100 │ 3.49 │ 0.303 │ 4.49 │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ 65-74 years       │     100 │ 4.44 │ 0.431 │ 5.03 │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ 75 years and over │     100 │ 5.53 │ 0.494 │ 5.59 │ #> └───────────────────┴─────────┴──────┴───────┴──────┘ #>  #> Association between Number of medications coded and Patient age recode {NAMCS 2019 PUF} #> ┌──────────────┬──────────────┐ #> │      p-value │ Flag         │ #> ├──────────────┼──────────────┤ #> │            0 │ *            │ #> └──────────────┴──────────────┘ #>   Wald test. *: p <= 0.05       #>  #> Comparison of Number of medications coded across all possible pairs of Patient age recode {NAMCS 2019 PUF} #> ┌────────────────┬───────────────────┬─────────┬──────┐ #> │ Level 1        │ Level 2           │ p-value │ Flag │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ Under 15 years │ 15-24 years       │   0.739 │      │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ Under 15 years │ 25-44 years       │   0.043 │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ Under 15 years │ 45-64 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ Under 15 years │ 65-74 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ Under 15 years │ 75 years and over │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 15-24 years    │ 25-44 years       │   0.029 │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 15-24 years    │ 45-64 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 15-24 years    │ 65-74 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 15-24 years    │ 75 years and over │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 25-44 years    │ 45-64 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 25-44 years    │ 65-74 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 25-44 years    │ 75 years and over │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 45-64 years    │ 65-74 years       │   0.007 │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 45-64 years    │ 75 years and over │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 65-74 years    │ 75 years and over │   0.002 │ *    │ #> └────────────────┴───────────────────┴─────────┴──────┘ #>   Design-based t-test. *: p <= 0.05                     #>"},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset_rate.html","id":null,"dir":"Reference","previous_headings":"","what":"Calculate rates for subsets — tab_subset_rate","title":"Calculate rates for subsets — tab_subset_rate","text":"Create subsets survey using one variable, tabulate rates another variable within subsets.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset_rate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Calculate rates for subsets — tab_subset_rate","text":"","code":"tab_subset_rate(   vr,   vrby,   pop,   lvls = c(),   per = getOption(\"surveytable.rate_per\"),   drop_na = getOption(\"surveytable.drop_na\"),   max_levels = getOption(\"surveytable.max_levels\"),   csv = getOption(\"surveytable.csv\") )"},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset_rate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Calculate rates for subsets — tab_subset_rate","text":"vr variable tabulate vrby use variable subset survey pop data.frame columns named Level, Subset, Population. Level must exactly match levels vr. Subset must exactly match levels vrby. Population population level vr vrby. lvls (optional) show levels vrby per calculate rate per many items population drop_na drop missing values (NA)? max_levels categorical variable can many levels. Used avoid printing huge tables. csv name CSV file","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset_rate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Calculate rates for subsets — tab_subset_rate","text":"list tables single table.","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset_rate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Calculate rates for subsets — tab_subset_rate","text":"","code":"set_survey(namcs2019sv) #> * Mode: General. #>                         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_subset_rate(\"AGER\", \"SEX\", uspop2019$`AGER x SEX`) #> Patient age recode (Patient sex = Female) (rate per 100 population) {NAMCS 2019 PUF} #> ┌───────────────────┬───────┬───────┬──────┬───────┬───────┐ #> │ Level             │     n │  Rate │   SE │    LL │    UL │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ Under 15 years    │   434 │ 202.5 │ 24.3 │ 159.8 │ 256.6 │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ 15-24 years       │   346 │ 198.4 │ 21.9 │ 159.5 │ 246.8 │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ 25-44 years       │   923 │ 263.3 │ 26.5 │ 215.9 │ 321   │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ 45-64 years       │ 1,253 │ 414   │ 37.7 │ 346.2 │ 495.1 │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ 65-74 years       │   891 │ 720.3 │ 66.4 │ 600.8 │ 863.6 │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ 75 years and over │   762 │ 758.1 │ 89.2 │ 601.2 │ 956   │ #> └───────────────────┴───────┴───────┴──────┴───────┴───────┘ #>   N = 4609.                                                  #>  #> Patient age recode (Patient sex = Male) (rate per 100 population) {NAMCS 2019 PUF} #> ┌───────────────────┬───────┬───────┬──────┬───────┬───────┐ #> │ Level             │     n │  Rate │   SE │    LL │    UL │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ Under 15 years    │   453 │ 187.4 │ 25   │ 144.1 │ 243.7 │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ 15-24 years       │   196 │ 113.1 │ 20.7 │  78.4 │ 163   │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ 25-44 years       │   512 │ 133.4 │ 17.2 │ 103.4 │ 172   │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ 45-64 years       │ 1,030 │ 333.4 │ 32.3 │ 275.4 │ 403.5 │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ 65-74 years       │   770 │ 594.8 │ 46.4 │ 510.1 │ 693.6 │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ 75 years and over │   680 │ 801.2 │ 73.2 │ 669.1 │ 959.5 │ #> └───────────────────┴───────┴───────┴──────┴───────┴───────┘ #>   N = 3641.                                                  #>"},{"path":"https://cdcgov.github.io/surveytable/reference/total.html","id":null,"dir":"Reference","previous_headings":"","what":"Total count — total","title":"Total count — total","text":"Total count","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/total.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Total count — total","text":"","code":"total(csv = getOption(\"surveytable.csv\"))"},{"path":"https://cdcgov.github.io/surveytable/reference/total.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Total count — total","text":"csv name CSV file","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/total.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Total count — total","text":"table","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/total.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Total count — total","text":"","code":"set_survey(namcs2019sv) #> * Mode: General. #>                         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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  total() #>                        Total {NAMCS 2019 PUF}                        #> ┌───────┬───────────────┬────────────┬─────────────┬───────────────┐ #> │     n │        Number │         SE │          LL │            UL │ #> ├───────┼───────────────┼────────────┼─────────────┼───────────────┤ #> │ 8,250 │ 1,036,484,356 │ 48,836,217 │ 945,013,590 │ 1,136,808,860 │ #> └───────┴───────────────┴────────────┴─────────────┴───────────────┘ #>   N = 8250.                                                          #>"},{"path":"https://cdcgov.github.io/surveytable/reference/total_rate.html","id":null,"dir":"Reference","previous_headings":"","what":"Overall rate — total_rate","title":"Overall rate — total_rate","text":"Overall rate","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/total_rate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Overall rate — total_rate","text":"","code":"total_rate(   pop,   per = getOption(\"surveytable.rate_per\"),   csv = getOption(\"surveytable.csv\") )"},{"path":"https://cdcgov.github.io/surveytable/reference/total_rate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Overall rate — total_rate","text":"pop population per calculate rate per many items population csv name CSV file","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/total_rate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Overall rate — total_rate","text":"table","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/total_rate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Overall rate — total_rate","text":"","code":"set_survey(namcs2019sv) #> * Mode: General. #>                         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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  total_rate(uspop2019$total) #> Total (rate per 100 population) {NAMCS 2019 PUF} #> ┌───────┬───────┬──────┬───────┬───────┐ #> │     n │  Rate │   SE │    LL │    UL │ #> ├───────┼───────┼──────┼───────┼───────┤ #> │ 8,250 │ 320.7 │ 15.1 │ 292.4 │ 351.7 │ #> └───────┴───────┴──────┴───────┴───────┘ #>   N = 8250.                              #>"},{"path":"https://cdcgov.github.io/surveytable/reference/uspop2019.html","id":null,"dir":"Reference","previous_headings":"","what":"US Population in 2019 — uspop2019","title":"US Population in 2019 — uspop2019","text":"Population estimates civilian non-institutional population United States July 1, 2019. Used calculating rates. usage examples, see *_rate functions.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/uspop2019.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"US Population in 2019 — uspop2019","text":"","code":"uspop2019"},{"path":"https://cdcgov.github.io/surveytable/reference/uspop2019.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"US Population in 2019 — uspop2019","text":"object class list length 7.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_all.html","id":null,"dir":"Reference","previous_headings":"","what":"Are all the variables true? (Logical AND) — var_all","title":"Are all the variables true? (Logical AND) — var_all","text":"Create new variable true variables list variables true.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_all.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Are all the variables true? (Logical AND) — var_all","text":"","code":"var_all(newvr, vrs)"},{"path":"https://cdcgov.github.io/surveytable/reference/var_all.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Are all the variables true? (Logical AND) — var_all","text":"newvr name new variable created vrs vector logical variables","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_all.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Are all the variables true? (Logical AND) — var_all","text":"Survey object","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/var_all.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Are all the variables true? (Logical AND) — var_all","text":"","code":"set_survey(namcs2019sv) #> * Mode: General. #>                         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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  var_all(\"Medicare and Medicaid\", c(\"PAYMCARE\", \"PAYMCAID\")) tab(\"Medicare and Medicaid\") #>                                 Medicare and Medicaid {NAMCS 2019 PUF}                                 #> ┌───────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ FALSE │ 8,126 │ 1,016,202,0 │ 47,395,074 │ 927,388,977 │ 1,113,520,4 │      98 │ 0.5 │ 96.9 │ 98.9 │ #> │       │       │          62 │            │             │          92 │         │     │      │      │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ TRUE  │   124 │  20,282,295 │  5,177,254 │  12,120,309 │  33,940,676 │       2 │ 0.5 │  1.1 │  3.1 │ #> └───────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                            #>"},{"path":"https://cdcgov.github.io/surveytable/reference/var_any.html","id":null,"dir":"Reference","previous_headings":"","what":"Is any variable true? (Logical OR) — var_any","title":"Is any variable true? (Logical OR) — var_any","text":"Create new variable true variables list variables true.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_any.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is any variable true? (Logical OR) — var_any","text":"","code":"var_any(newvr, vrs)"},{"path":"https://cdcgov.github.io/surveytable/reference/var_any.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is any variable true? (Logical OR) — var_any","text":"newvr name new variable created vrs vector logical variables","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_any.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is any variable true? (Logical OR) — var_any","text":"Survey object","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/var_any.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is any variable true? (Logical OR) — var_any","text":"","code":"set_survey(namcs2019sv) #> * Mode: General. #>                         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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  var_any(\"Imaging services\" , c(\"ANYIMAGE\", \"BONEDENS\", \"CATSCAN\", \"ECHOCARD\", \"OTHULTRA\" , \"MAMMO\", \"MRI\", \"XRAY\", \"OTHIMAGE\")) tab(\"Imaging services\") #>                                   Imaging services {NAMCS 2019 PUF}                                    #> ┌───────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ FALSE │ 7,148 │ 901,115,076 │ 43,298,146 │ 820,085,161 │ 990,151,291 │    86.9 │ 1.1 │ 84.6 │ 89.1 │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ TRUE  │ 1,102 │ 135,369,280 │ 13,573,736 │ 111,133,847 │ 164,889,838 │    13.1 │ 1.1 │ 10.9 │ 15.4 │ #> └───────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                            #>"},{"path":"https://cdcgov.github.io/surveytable/reference/var_case.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert factor to logical — var_case","title":"Convert factor to logical — var_case","text":"Convert factor logical","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_case.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert factor to logical — var_case","text":"","code":"var_case(newvr, vr, cases, retain_na = TRUE)"},{"path":"https://cdcgov.github.io/surveytable/reference/var_case.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert factor to logical — var_case","text":"newvr name new logical variable created vr factor variable cases one levels vr converted TRUE. levels converted FALSE. retain_na observations vr NA, newvr NA well?","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_case.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert factor to logical — var_case","text":"Survey object","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/var_case.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert factor to logical — var_case","text":"","code":"set_survey(namcs2019sv) #> * Mode: General. #>                         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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>   var_case(\"Preventive care visits\", \"MAJOR\", \"Preventive care\") tab(\"Preventive care visits\") #>                                Preventive care visits {NAMCS 2019 PUF}                                 #> ┌───────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ FALSE │ 6,682 │ 812,860,686 │ 45,220,483 │ 728,841,389 │ 906,565,549 │    78.4 │ 1.7 │ 74.9 │ 81.7 │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ TRUE  │ 1,568 │ 223,623,671 │ 18,519,789 │ 190,068,005 │ 263,103,441 │    21.6 │ 1.7 │ 18.3 │ 25.1 │ #> └───────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                            #>   var_case(\"Surgery-related visits\" , \"MAJOR\" , c(\"Pre-surgery\", \"Post-surgery\")) tab(\"Surgery-related visits\") #>                                Surgery-related visits {NAMCS 2019 PUF}                                 #> ┌───────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ FALSE │ 7,432 │ 969,450,753 │ 47,976,379 │ 879,792,684 │ 1,068,245,7 │    93.5 │ 0.8 │ 91.9 │ 94.9 │ #> │       │       │             │            │             │          12 │         │     │      │      │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ TRUE  │   818 │  67,033,604 │  7,810,237 │  53,273,079 │  84,348,494 │     6.5 │ 0.8 │  5.1 │  8.1 │ #> └───────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                            #>   var_case(\"Non-primary\" , \"SPECCAT.bad\" , c(\"Surgical care specialty\", \"Medical care specialty\")) tab(\"Non-primary\") #>                                      Non-primary {NAMCS 2019 PUF}                                      #> ┌───────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ FALSE │ 2,406 │ 422,806,843 │ 26,381,877 │ 374,098,520 │ 477,857,080 │    40.8 │ 2.2 │ 36.5 │ 45.2 │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ TRUE  │ 4,194 │ 406,215,659 │ 32,642,950 │ 346,937,333 │ 475,622,385 │    39.2 │ 2.1 │ 35   │ 43.5 │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │  │ 1,650 │ 207,461,854 │ 12,457,774 │ 184,377,795 │ 233,436,032 │    20   │ 0.8 │ 18.5 │ 21.6 │ #> └───────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                            #>  tab(\"Non-primary\", drop_na = TRUE) #>                               Non-primary (knowns only) {NAMCS 2019 PUF}                               #> ┌───────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ FALSE │ 2,406 │ 422,806,843 │ 26,381,877 │ 374,098,520 │ 477,857,080 │      51 │ 2.6 │ 45.7 │ 56.3 │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ TRUE  │ 4,194 │ 406,215,659 │ 32,642,950 │ 346,937,333 │ 475,622,385 │      49 │ 2.6 │ 43.7 │ 54.3 │ #> └───────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 6600.                                                                                            #>"},{"path":"https://cdcgov.github.io/surveytable/reference/var_collapse.html","id":null,"dir":"Reference","previous_headings":"","what":"Collapse factor levels — var_collapse","title":"Collapse factor levels — var_collapse","text":"Collapse two levels factor variable single level.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_collapse.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Collapse factor levels — var_collapse","text":"","code":"var_collapse(vr, newlevel, oldlevels)"},{"path":"https://cdcgov.github.io/surveytable/reference/var_collapse.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Collapse factor levels — var_collapse","text":"vr factor variable newlevel name new level oldlevels vector old levels","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_collapse.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Collapse factor levels — var_collapse","text":"Survey object","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/var_collapse.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Collapse factor levels — var_collapse","text":"","code":"set_survey(namcs2019sv) #> * Mode: General. #>                         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(\"PRIMCARE\") #>                      Are you the patient's primary care provider? {NAMCS 2019 PUF}                       #> ┌─────────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level   │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├─────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Blank   │    16 │   1,150,066 │    478,377 │     440,081 │   3,005,475 │     0.1 │ 0   │  0   │  0.2 │ #> ├─────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Unknown │   300 │  39,518,576 │  9,507,422 │  24,519,903 │  63,691,845 │     3.8 │ 0.9 │  2.3 │  6   │ #> ├─────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Yes     │ 2,278 │ 383,480,893 │ 28,554,963 │ 331,361,656 │ 443,797,864 │    37   │ 2.6 │ 31.9 │ 42.3 │ #> ├─────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ No      │ 5,656 │ 612,334,822 │ 43,282,478 │ 533,049,777 │ 703,412,608 │    59.1 │ 2.5 │ 53.9 │ 64.1 │ #> └─────────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                              #>  var_collapse(\"PRIMCARE\", \"Unknown if PCP\", c(\"Blank\", \"Unknown\")) tab(\"PRIMCARE\") #>                        Are you the patient's primary care provider? {NAMCS 2019 PUF}                         #> ┌─────────────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level       │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Unknown if  │   316 │  40,668,642 │  9,478,963 │  25,618,707 │  64,559,793 │     3.9 │ 0.9 │  2.4 │  6.1 │ #> │ PCP         │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Yes         │ 2,278 │ 383,480,893 │ 28,554,963 │ 331,361,656 │ 443,797,864 │    37   │ 2.6 │ 31.9 │ 42.3 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ No          │ 5,656 │ 612,334,822 │ 43,282,478 │ 533,049,777 │ 703,412,608 │    59.1 │ 2.5 │ 53.9 │ 64.1 │ #> └─────────────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                                  #>"},{"path":"https://cdcgov.github.io/surveytable/reference/var_copy.html","id":null,"dir":"Reference","previous_headings":"","what":"Copy a variable — var_copy","title":"Copy a variable — var_copy","text":"Create new variable copy another variable. can modify copy, original remains unchanged. See examples.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_copy.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Copy a variable — var_copy","text":"","code":"var_copy(newvr, vr)"},{"path":"https://cdcgov.github.io/surveytable/reference/var_copy.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Copy a variable — var_copy","text":"newvr name new variable created vr variable","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_copy.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Copy a variable — var_copy","text":"Survey object","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/var_copy.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Copy a variable — var_copy","text":"","code":"set_survey(namcs2019sv) #> * Mode: General. #>                         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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  var_copy(\"Age group\", \"AGER\") var_collapse(\"Age group\", \"65+\", c(\"65-74 years\", \"75 years and over\")) var_collapse(\"Age group\", \"25-64\", c(\"25-44 years\", \"45-64 years\")) tab(\"AGER\", \"Age group\") #>                                     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.                                                                                                  #>  #>                                          Age group {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-64       │ 3,718 │ 479,776,560 │ 32,174,693 │ 420,624,423 │ 547,247,222 │    46.3 │ 1.8 │ 42.7 │ 49.9 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 65+         │ 3,103 │ 373,935,326 │ 24,522,516 │ 328,776,878 │ 425,296,417 │    36.1 │ 1.9 │ 32.3 │ 40   │ #> └─────────────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                                  #>"},{"path":"https://cdcgov.github.io/surveytable/reference/var_cross.html","id":null,"dir":"Reference","previous_headings":"","what":"Cross or interact two variables — var_cross","title":"Cross or interact two variables — var_cross","text":"Create new variable interaction two variables. Also see tab_cross().","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_cross.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cross or interact two variables — var_cross","text":"","code":"var_cross(newvr, vr, vrby)"},{"path":"https://cdcgov.github.io/surveytable/reference/var_cross.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cross or interact two variables — var_cross","text":"newvr name new variable created vr first variable vrby second variable","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_cross.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cross or interact two variables — var_cross","text":"Survey object","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/var_cross.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cross or interact two variables — var_cross","text":"","code":"set_survey(namcs2019sv) #> * Mode: General. #>                         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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  var_cross(\"Age x Sex\", \"AGER\", \"SEX\") tab(\"Age x Sex\") #>                                          Age x Sex {NAMCS 2019 PUF}                                          #> ┌─────────────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level       │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Under 15    │   434 │  59,957,823 │  7,205,594 │  47,318,228 │  75,973,693 │     5.8 │ 0.7 │  4.5 │  7.3 │ #> │ years:      │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 15-24       │   346 │  41,128,003 │  4,532,466 │  33,065,609 │  51,156,253 │     4   │ 0.4 │  3.2 │  4.9 │ #> │ years:      │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 25-44       │   923 │ 113,708,461 │ 11,461,189 │  93,256,445 │ 138,645,797 │    11   │ 1   │  9   │ 13.2 │ #> │ years:      │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 45-64       │ 1,253 │ 175,978,133 │ 16,008,541 │ 147,152,826 │ 210,449,940 │    17   │ 1.1 │ 14.8 │ 19.3 │ #> │ years:      │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 65-74       │   891 │ 120,099,493 │ 11,066,146 │ 100,171,315 │ 143,992,203 │    11.6 │ 1   │  9.7 │ 13.7 │ #> │ years:      │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 75 years    │   762 │  94,173,155 │ 11,085,372 │  74,682,310 │ 118,750,789 │     9.1 │ 0.9 │  7.3 │ 11.1 │ #> │ and over:   │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Under 15    │   453 │  57,958,950 │  7,727,594 │  44,569,688 │  75,370,504 │     5.6 │ 0.7 │  4.3 │  7.2 │ #> │ years: Male │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 15-24       │   196 │  23,727,695 │  4,343,932 │  16,457,071 │  34,210,431 │     2.3 │ 0.4 │  1.6 │  3.2 │ #> │ years: Male │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 25-44       │   512 │  56,562,143 │  7,276,983 │  43,860,836 │  72,941,520 │     5.5 │ 0.6 │  4.3 │  6.8 │ #> │ years: Male │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 45-64       │ 1,030 │ 133,527,822 │ 12,956,239 │ 110,319,199 │ 161,619,006 │    12.9 │ 1   │ 10.9 │ 15.1 │ #> │ years: Male │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 65-74       │   770 │  86,766,489 │  6,766,876 │  74,409,284 │ 101,175,865 │     8.4 │ 0.6 │  7.2 │  9.7 │ #> │ years: Male │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 75 years    │   680 │  72,896,189 │  6,660,855 │  60,871,965 │  87,295,593 │     7   │ 0.6 │  5.9 │  8.3 │ #> │ and over:   │       │             │            │             │             │         │     │      │      │ #> │ Male        │       │             │            │             │             │         │     │      │      │ #> └─────────────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                                  #>"},{"path":"https://cdcgov.github.io/surveytable/reference/var_cut.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert numeric to factor — var_cut","title":"Convert numeric to factor — var_cut","text":"Create new categorical variable based numeric variable.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_cut.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert numeric to factor — var_cut","text":"","code":"var_cut(newvr, vr, breaks, labels)"},{"path":"https://cdcgov.github.io/surveytable/reference/var_cut.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert numeric to factor — var_cut","text":"newvr name new factor variable created vr numeric variable breaks see cut() labels see cut()","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_cut.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert numeric to factor — var_cut","text":"Survey object","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/var_cut.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert numeric to factor — var_cut","text":"","code":"set_survey(namcs2019sv) #> * Mode: General. #>                         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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  # In some data systems, variables might contain \"special values\". For example, # negative values might indicate unknowns (which should be coded as `NA`). # Though in this particular data, there are no unknowns. var_cut(\"Age group\"   , \"AGE\"   , c(-Inf, -0.1, 0, 4, 14, 64, Inf)   , c(NA, \"Under 1\", \"1-4\", \"5-14\", \"15-64\", \"65 and over\")) tab(\"Age group\") #>                                          Age group {NAMCS 2019 PUF}                                          #> ┌─────────────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level       │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Under 1     │   203 │  31,147,553 │  5,281,607 │  22,269,146 │  43,565,662 │     3   │ 0.5 │  2.1 │  4.1 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 1-4         │   281 │  38,240,087 │  5,443,933 │  28,863,791 │  50,662,237 │     3.7 │ 0.5 │  2.7 │  4.8 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 5-14        │   403 │  48,529,132 │  5,741,214 │  38,429,869 │  61,282,455 │     4.7 │ 0.5 │  3.7 │  5.9 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 15-64       │ 4,260 │ 544,632,258 │ 36,082,093 │ 478,254,001 │ 620,223,345 │    52.5 │ 2   │ 48.6 │ 56.5 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 65 and over │ 3,103 │ 373,935,326 │ 24,522,516 │ 328,776,878 │ 425,296,417 │    36.1 │ 1.9 │ 32.3 │ 40   │ #> └─────────────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                                  #>"},{"path":"https://cdcgov.github.io/surveytable/reference/var_list.html","id":null,"dir":"Reference","previous_headings":"","what":"List variables in a survey. — var_list","title":"List variables in a survey. — var_list","text":"List variables survey.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_list.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"List variables in a survey. — var_list","text":"","code":"var_list(sw = \"\", all = FALSE, csv = getOption(\"surveytable.csv\"))"},{"path":"https://cdcgov.github.io/surveytable/reference/var_list.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"List variables in a survey. — var_list","text":"sw starting characters variable name (case insensitive) print variables? csv name CSV file","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_list.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"List variables in a survey. — var_list","text":"table","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_list.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"List variables in a survey. — var_list","text":"","code":"set_survey(namcs2019sv) #> * Mode: General. #>                         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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  var_list(\"age\") #>          Variables beginning with 'age' {NAMCS 2019 PUF}          #> ┌──────────┬─────────┬──────────────────────────────────────────┐ #> │ Variable │ Class   │ Long name                                │ #> ├──────────┼─────────┼──────────────────────────────────────────┤ #> │ AGE      │ numeric │ Patient age in years (raw - use caution) │ #> ├──────────┼─────────┼──────────────────────────────────────────┤ #> │ AGER     │ factor  │ Patient age recode                       │ #> └──────────┴─────────┴──────────────────────────────────────────┘ #>"},{"path":"https://cdcgov.github.io/surveytable/reference/var_not.html","id":null,"dir":"Reference","previous_headings":"","what":"Logical NOT — var_not","title":"Logical NOT — var_not","text":"Logical ","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_not.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Logical NOT — var_not","text":"","code":"var_not(newvr, vr)"},{"path":"https://cdcgov.github.io/surveytable/reference/var_not.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Logical NOT — var_not","text":"newvr name new variable created vr logical variable","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_not.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Logical NOT — var_not","text":"Survey object","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/var_not.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Logical NOT — var_not","text":"","code":"set_survey(namcs2019sv) #> * Mode: General. #>                         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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  var_not(\"Private insurance not used\", \"PAYPRIV\")"},{"path":"https://cdcgov.github.io/surveytable/news/index.html","id":"surveytable-development-version","dir":"Changelog","previous_headings":"","what":"surveytable (development version)","title":"surveytable (development version)","text":"rccsu2018 set_mode()","code":""},{"path":"https://cdcgov.github.io/surveytable/news/index.html","id":"surveytable-094","dir":"Changelog","previous_headings":"","what":"surveytable 0.9.4","title":"surveytable 0.9.4","text":"CRAN release: 2024-05-20 Optionally adjust p-values multiple comparisons (p_adjust argument)","code":""},{"path":"https://cdcgov.github.io/surveytable/news/index.html","id":"surveytable-093","dir":"Changelog","previous_headings":"","what":"surveytable 0.9.3","title":"surveytable 0.9.3","text":"codebook() Improved output. Allows unweighted survey data.frame. Can set certain options using argument. Tabulation functions show number observations. LaTeX printing.","code":""},{"path":"https://cdcgov.github.io/surveytable/news/index.html","id":"surveytable-092","dir":"Changelog","previous_headings":"","what":"surveytable 0.9.2","title":"surveytable 0.9.2","text":"CRAN release: 2024-01-18 Addressed CRAN comments.","code":""},{"path":"https://cdcgov.github.io/surveytable/news/index.html","id":"surveytable-091","dir":"Changelog","previous_headings":"","what":"surveytable 0.9.1","title":"surveytable 0.9.1","text":"Initial CRAN submission.","code":""}]
    +[{"path":"https://cdcgov.github.io/surveytable/articles/Advanced-topics.html","id":"subsetting-a-survey","dir":"Articles","previous_headings":"","what":"Subsetting a survey","title":"Advanced topics","text":"Consider example, estimate number medications age group: Survey info {NAMCS 2019 PUF} Number medications coded (different levels Patient age recode) {NAMCS 2019 PUF} ’d like estimate thing, visits NUMMED > 0? One way create another survey object NUMMED > 0, analyze new survey object. Survey info {NAMCS 2019 PUF: NUMMED 1+} Note called set_survey(), let R know now want analyze new object newsurvey, namcs2019sv. Now, let’s create table: Number medications coded (different levels Patient age recode) {NAMCS 2019 PUF: NUMMED 1+} sure check table title verify tabulating new survey object.","code":"library(surveytable) set_survey(namcs2019sv) tab_subset(\"NUMMED\", \"AGER\") newsurvey = survey_subset(namcs2019sv, NUMMED > 0   , label = \"NAMCS 2019 PUF: NUMMED 1+\") set_survey(newsurvey) tab_subset(\"NUMMED\", \"AGER\")"},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/articles/Advanced-topics.html","id":"advanced-variable-editing","dir":"Articles","previous_headings":"Advanced variable editing and data flow","what":"Advanced variable editing","title":"Advanced topics","text":"First, let’s review call “advanced variable editing”. surveytable provides number functions create modify survey variables. examples include [var_collapse()] [var_cut()]. Occasionally, might need advanced variable editing. ’s : Every survey object element called variables data frame survey’s variables located Create new variable variables data frame (part survey object). Call set_survey() . time modify variables data frame, call set_survey(). Tabulate new variable. example , see vignette(\"Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report\").","code":""},{"path":"https://cdcgov.github.io/surveytable/articles/Advanced-topics.html","id":"data-flow","dir":"Articles","previous_headings":"Advanced variable editing and data flow","what":"Data flow","title":"Advanced topics","text":"explanation raises question set_survey() must called , variables modified. explanation: survey ’re analyzing actually exists three separate places: file computer data storage contains survey object. example, RDS file hard disk drive contains survey object named something like mysurvey.rds. survey object R’s global environment, named something like mysurvey. hidden copy survey object ’s used surveytable. surveytable analyzes. (3) ’s different (2), might ask. ’s due arcane issue R packages work – (2) (3) necessary. Normally, information flows forwards, (1) (2) (2) (3). Forwards flow: Going (1) (2): call readRDS(). Going (2) (3): call set_survey(). Backwards flow: Going (3) (2): probably don’t need , see . really need , call surveytable:::.load_survey(). Going (2) (1): call saveRDS(). Normally, probably don’t want . Normally, survey file (mysurvey.rds) probably changed. functions modifying creating variables part surveytable package (like var_cut() var_collapse()) modify (3). Since (3) surveytable works tabulates, can call var_collapse(), can call tab(). don’t need anything extra . modifying variables data frame directly, actually modifying (2). modify (2), need copy (3), surveytable can use . calling set_survey(). Thus, time modify variables , call set_survey(). modify (2), copy (2) -> (3) calling set_survey(). flip side, changes make (3) (using surveytable functions like var_cut() var_collapse()) reflected (2). make changes (3), call set_survey(), changes lost, set_survey() copies (2) -> (3). changes important, can just rerun code created . really need go (3) (2), use mysurvey = surveytable:::.load_survey().","code":""},{"path":"https://cdcgov.github.io/surveytable/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html","id":"begin","dir":"Articles","previous_headings":"","what":"Begin","title":"Example: National Ambulatory Medical Care Survey (NAMCS) tables","text":"Begin loading surveytable package. , print message explaining specify survey ’d like analyze. omitting message . Now, specify survey ’d like analyze. Survey info {NAMCS 2019 PUF} Check survey name, survey design variables, number observations verify looks correct. example, want turn certain NCHS-specific options, identifying low-precision estimates. care identifying low-precision estimates, can skip command. turn NCHS-specific options:","code":"library(surveytable) set_survey(namcs2019sv) set_opts(mode = \"NCHS\") ## * Mode: NCHS."},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html","id":"counts-and-percentages","dir":"Articles","previous_headings":"Table 1","what":"Counts and percentages","title":"Example: National Ambulatory Medical Care Survey (NAMCS) tables","text":"table shows overall estimated count well counts percentages type doctor, physician specialty, metropolitan statistical area. variables necessary creating table already survey, making commands straightforward. Total {NAMCS 2019 PUF} Type doctor (MD ) {NAMCS 2019 PUF} Type specialty (Primary, Medical, Surgical) {NAMCS 2019 PUF} Metropolitan Statistical Area Status physician location {NAMCS 2019 PUF}","code":"total() tab(\"MDDO\", \"SPECCAT\", \"MSA\")"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html","id":"rates","dir":"Articles","previous_headings":"Table 1","what":"Rates","title":"Example: National Ambulatory Medical Care Survey (NAMCS) tables","text":"published table also shows several rates. calculate rates, addition survey, need source information population estimates. typically use function read.csv() load population estimates get correct format. surveytable package comes object called uspop2019 contains several population estimates use examples. overall population estimate: overall population estimate, overall rate : Total (rate per 100 population) {NAMCS 2019 PUF} calculate rates particular variable, need provide data frame variable called Level matches levels variable survey, variable called Population gives population size (assumed constant rather random variable). MSA, can see levels variables just using tab() command, just . Thus, calculate rates, need data frame follows: Now appropriate population estimates, rate : Metropolitan Statistical Area Status physician location (rate per 100 population) {NAMCS 2019 PUF} can also calculate rates specific variable based entire population: Type doctor (MD ) (rate per 100 population) {NAMCS 2019 PUF} Type specialty (Primary, Medical, Surgical) (rate per 100 population) {NAMCS 2019 PUF}","code":"class(uspop2019) ## [1] \"list\" names(uspop2019) ## [1] \"total\"       \"MSA\"         \"AGER\"        \"Age group\"   \"SEX\"         ## [6] \"AGER x SEX\"  \"Age group 5\" uspop2019$total ## [1] 323186697 total_rate(uspop2019$total) uspop2019$MSA ##                                 Level Population ## 1 MSA (Metropolitan Statistical Area)  277229518 ## 2                             Non-MSA   45957179 tab_rate(\"MSA\", uspop2019$MSA) tab_rate(\"MDDO\", uspop2019$total) ## * Rate based on the entire population. tab_rate(\"SPECCAT\", uspop2019$total) ## * Rate based on the entire population."},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html","id":"counts-and-percentages-1","dir":"Articles","previous_headings":"Table 3","what":"Counts and percentages","title":"Example: National Ambulatory Medical Care Survey (NAMCS) tables","text":"table presents estimates age group, well age group sex. Variables beginning ‘age’ {NAMCS 2019 PUF} survey couple relevant age-related variables. AGE patient age years. AGER categorical variable based AGE. However, table, addition AGER, need another age group variable, different age categories. create using var_cut function. Now ’ve created Age group variable, can create tables: Patient age recode {NAMCS 2019 PUF} Age group {NAMCS 2019 PUF} Patient sex {NAMCS 2019 PUF} (Patient age recode) x (Patient sex) {NAMCS 2019 PUF}","code":"var_list(\"age\") var_cut(\"Age group\", \"AGE\"         , c(-Inf, 0, 4, 14, 64, Inf)         , c(\"Under 1\", \"1-4\", \"5-14\", \"15-64\", \"65 and over\") ) tab(\"AGER\", \"Age group\", \"SEX\") tab_cross(\"AGER\", \"SEX\")"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html","id":"rates-1","dir":"Articles","previous_headings":"Table 3","what":"Rates","title":"Example: National Ambulatory Medical Care Survey (NAMCS) tables","text":"Patient age recode (rate per 100 population) {NAMCS 2019 PUF} Age group (rate per 100 population) {NAMCS 2019 PUF} Patient sex (rate per 100 population) {NAMCS 2019 PUF} calculate rates one variable (AGER) another variable (SEX), need population estimates following format: population estimates, rates : Patient age recode (Patient sex = Female) (rate per 100 population) {NAMCS 2019 PUF} Patient age recode (Patient sex = Male) (rate per 100 population) {NAMCS 2019 PUF}","code":"tab_rate(\"AGER\", uspop2019$AGER) tab_rate(\"Age group\", uspop2019$`Age group`) ## * Population for some levels not defined: 15-64 tab_rate(\"SEX\", uspop2019$SEX) uspop2019$`AGER x SEX` ##                Level Subset Population ## 1     Under 15 years Female   29604762 ## 2        15-24 years Female   20730118 ## 3        25-44 years Female   43192143 ## 4        45-64 years Female   42508901 ## 5        65-74 years Female   16673240 ## 6  75 years and over Female   12421444 ## 7     Under 15 years   Male   30921894 ## 8        15-24 years   Male   20988582 ## 9        25-44 years   Male   42407267 ## 10       45-64 years   Male   40053148 ## 11       65-74 years   Male   14586962 ## 12 75 years and over   Male    9098236 tab_subset_rate(\"AGER\", \"SEX\", uspop2019$`AGER x SEX`)"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html","id":"table-5","dir":"Articles","previous_headings":"","what":"Table 5","title":"Example: National Ambulatory Medical Care Survey (NAMCS) tables","text":"table gives expected sources payment. use PAY* variables create several new variables required table. Note PAY* variables logical (TRUE FALSE), simplifies workflow. (survey imported R using importsurvey package, automatically detects binary variables imports logical variables.) Expected source payment visit: Private insurance {NAMCS 2019 PUF} Expected source payment visit: Medicare {NAMCS 2019 PUF} Expected source payment visit: Medicaid CHIP state-based program {NAMCS 2019 PUF} Medicare Medicaid {NAMCS 2019 PUF} insurance {NAMCS 2019 PUF} Self-pay {NAMCS 2019 PUF} charge {NAMCS 2019 PUF} Expected source payment visit: Workers Compensation {NAMCS 2019 PUF} Expected source payment visit: {NAMCS 2019 PUF} Unknown blank {NAMCS 2019 PUF} Check presentation standards flags! NCHS presentation standards rules, estimates shown.","code":"# var_all(\"Medicare and Medicaid\", c(\"PAYMCARE\", \"PAYMCAID\"))  # var_any(\"Payment used\", c(\"PAYPRIV\", \"PAYMCARE\", \"PAYMCAID\"   , \"PAYWKCMP\", \"PAYOTH\", \"PAYDK\")) var_not(\"No other payment used\", \"Payment used\")  var_all(\"Self-pay\", c(\"PAYSELF\", \"No other payment used\")) var_all(\"No charge\", c(\"PAYNOCHG\", \"No other payment used\")) var_any(\"No insurance\", c(\"Self-pay\", \"No charge\"))  # var_case(\"No pay\", \"NOPAY\", \"No categories marked\") var_any(\"Unknown or blank\", c(\"PAYDK\", \"No pay\"))  ## tab(\"PAYPRIV\", \"PAYMCARE\", \"PAYMCAID\", \"Medicare and Medicaid\"   , \"No insurance\", \"Self-pay\", \"No charge\"   , \"PAYWKCMP\", \"PAYOTH\", \"Unknown or blank\")"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html","id":"table-6","dir":"Articles","previous_headings":"","what":"Table 6","title":"Example: National Ambulatory Medical Care Survey (NAMCS) tables","text":"table shows primary care provider referral status, prior-visit status. table, “Unknown” “Blank” values collapsed single value. can collapse two levels factor single level using var_collapse function. Now, table: patient’s primary care provider? {NAMCS 2019 PUF} patient referred visit? {NAMCS 2019 PUF} patient seen practice ? {NAMCS 2019 PUF} percentages within subset defined SENBEFOR add 100% – reason, want use tab_subset(), tab_cross(). patient’s primary care provider? (patient seen practice ? = Yes, established patient) {NAMCS 2019 PUF} patient’s primary care provider? (patient seen practice ? = , new patient) {NAMCS 2019 PUF} patient referred visit? (patient seen practice ? = Yes, established patient) {NAMCS 2019 PUF} patient referred visit? (patient seen practice ? = , new patient) {NAMCS 2019 PUF}","code":"var_collapse(\"PRIMCARE\", \"Unknown if PCP\", c(\"Unknown\", \"Blank\")) var_collapse(\"REFER\", \"Unknown if referred\", c(\"Unknown\", \"Blank\")) tab(\"PRIMCARE\", \"REFER\", \"SENBEFOR\") tab_subset(\"PRIMCARE\", \"SENBEFOR\") tab_subset(\"REFER\", \"SENBEFOR\")"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html","id":"table-11","dir":"Articles","previous_headings":"","what":"Table 11","title":"Example: National Ambulatory Medical Care Survey (NAMCS) tables","text":"table shows information Table 3, preventive care visits. , estimates age group, well age group sex, preventive care visits. Let’s create Age group AGE cross AGER SEX create variable called Age x Sex: see possible values MAJOR (Major reason visit), estimate total count preventive care visits: Major reason visit {NAMCS 2019 PUF} create tables age, sex, interaction, limit preventive care visits: Patient age recode (Major reason visit = Preventive care) {NAMCS 2019 PUF} Age group (Major reason visit = Preventive care) {NAMCS 2019 PUF} Patient sex (Major reason visit = Preventive care) {NAMCS 2019 PUF} Age x Sex (Major reason visit = Preventive care) {NAMCS 2019 PUF} commands similar, differs first variable passed tab_subset() function, code can streamlined loop: Patient age recode (Major reason visit = Preventive care) {NAMCS 2019 PUF} Age group (Major reason visit = Preventive care) {NAMCS 2019 PUF} Patient sex (Major reason visit = Preventive care) {NAMCS 2019 PUF} Age x Sex (Major reason visit = Preventive care) {NAMCS 2019 PUF} Note called inside loop, print() function needs called explicitly.","code":"var_cut(\"Age group\", \"AGE\"         , c(-Inf, 0, 4, 14, 64, Inf)         , c(\"Under 1\", \"1-4\", \"5-14\", \"15-64\", \"65 and over\") ) ## Warning in var_cut(\"Age group\", \"AGE\", c(-Inf, 0, 4, 14, 64, Inf), c(\"Under 1\", ## : Age group: overwriting a variable that already exists. var_cross(\"Age x Sex\", \"AGER\", \"SEX\") tab(\"MAJOR\") tab_subset(\"AGER\", \"MAJOR\", \"Preventive care\") tab_subset(\"Age group\", \"MAJOR\", \"Preventive care\") tab_subset(\"SEX\", \"MAJOR\", \"Preventive care\") tab_subset(\"Age x Sex\", \"MAJOR\", \"Preventive care\") for (vr in c(\"AGER\", \"Age group\", \"SEX\", \"Age x Sex\")) {     print( tab_subset(vr, \"MAJOR\", \"Preventive care\") ) }"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html","id":"more-advanced-coding","dir":"Articles","previous_headings":"Table 11","what":"More advanced coding","title":"Example: National Ambulatory Medical Care Survey (NAMCS) tables","text":"addition, age-sex category, published table shows percentage preventive care visits made primary care physicians. calculate percentages, slightly involved loop needed. code, followed explanation: Since tab_subset() called within loop, wanted print screen, need use print( tab_subset(*) ). Since don’t want print screen, call print() omitted. Since many tables produced, output sent CSV file. , loop goes age, sex, age / sex interaction variables, calling variables vr. MAJOR vr crossed, result stored variable called tmp. Next, inner loop goes levels vr, calling levels lvl. code tabulates SPECCAT (Type specialty – Primary, Medical, Surgical) subset tmp (MAJOR crossed vr) restricted \"Preventive care: \" followed lvl, level vr, “15 years” AGER. Finally, CSV output turned . run code, tables stored CSV file. give idea tables look like, just one tables: Type specialty (Primary, Medical, Surgical) (tmp = Preventive care: 15 years) {NAMCS 2019 PUF} match percentage published table, see “Primary care specialty” row. sure check presentation standards flags.","code":"set_opts(csv = \"output.csv\") for (vr in c(\"AGER\", \"Age group\", \"SEX\", \"Age x Sex\")) {     var_cross(\"tmp\", \"MAJOR\", vr)     for (lvl in levels(surveytable:::env$survey$variables[,vr])) {         tab_subset(\"SPECCAT\", \"tmp\", paste0(\"Preventive care: \", lvl))     } } ## Warning in var_cross(\"tmp\", \"MAJOR\", vr): tmp: overwriting a variable that ## already exists. ## Warning in var_cross(\"tmp\", \"MAJOR\", vr): tmp: overwriting a variable that ## already exists. ## Warning in var_cross(\"tmp\", \"MAJOR\", vr): tmp: overwriting a variable that ## already exists. set_opts(csv = \"\") ## * Turning off CSV output. vr = \"AGER\" var_cross(\"tmp\", \"MAJOR\", vr) ## Warning in var_cross(\"tmp\", \"MAJOR\", vr): tmp: overwriting a variable that ## already exists. lvl = levels(surveytable:::env$survey$variables[,vr])[1] tab_subset(\"SPECCAT\", \"tmp\", paste0(\"Preventive care: \", lvl))"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report.html","id":"begin","dir":"Articles","previous_headings":"","what":"Begin","title":"Example: Residential Care Community Services User (NSLTCP RCC SU) report","text":"Begin loading surveytable package. , print message explaining specify survey ’d like analyze. Now, specify survey ’d like analyze. Survey info {RCC SU 2018 PUF} Check survey name, survey design variables, number observations verify looks correct. example, want turn certain NCHS-specific options, identifying low-precision estimates. care identifying low-precision estimates, can skip command. turn NCHS-specific options: Alternatively, can combine two commands single command, like : Survey info {RCC SU 2018 PUF}","code":"library(surveytable) set_survey(rccsu2018) set_opts(mode = \"NCHS\") ## * Mode: NCHS. set_survey(rccsu2018, mode = \"NCHS\") ## * Mode: NCHS."},{"path":"https://cdcgov.github.io/surveytable/articles/Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report.html","id":"figure-1","dir":"Articles","previous_headings":"","what":"Figure 1","title":"Example: Residential Care Community Services User (NSLTCP RCC SU) report","text":"figure shows percentage residents sex, race / ethnicity, age group. Sex. Resident’s gender {RCC SU 2018 PUF} Race / ethnicity. Variables beginning ‘race’ {RCC SU 2018 PUF} Resident’s race/ethnicity {RCC SU 2018 PUF} published figure, Hispanic categories merged single category called “Another race ethnicity”. can using var_collapse() function. Resident’s race/ethnicity {RCC SU 2018 PUF} Age group. Variables beginning ‘age’ {RCC SU 2018 PUF} age2 numeric variable. need create categorical variable based numeric variable. done using var_cut() function. Age {RCC SU 2018 PUF}","code":"tab(\"sex\") var_list(\"race\") tab(\"raceeth2\") var_collapse(\"raceeth2\"              , \"Another race or ethnicity\"              , c(\"Hispanic\", \"Other\")) tab(\"raceeth2\") var_list(\"age\") var_cut(\"Age\", \"age2\"         , c(-Inf, 64, 74, 84, Inf)         , c(\"Under 65\", \"65-74\", \"75-84\", \"85 and over\") ) tab(\"Age\")"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report.html","id":"figure-2","dir":"Articles","previous_headings":"","what":"Figure 2","title":"Example: Residential Care Community Services User (NSLTCP RCC SU) report","text":"figure shows percentage residents Medicaid, overall age group. Used Medicaid pay services {RCC SU 2018 PUF} can see, observations, value variable unknown (’s missing NA). command calculates percentages based observations, including ones missing (NA) values. However, published figure, percentages based knowns . exclude NA’s calculation, use drop_na argument: Used Medicaid pay services (knowns ) {RCC SU 2018 PUF} Note table title alerts fact using known values . age group: Used Medicaid pay services (Age = 65) (knowns ) {RCC SU 2018 PUF} Used Medicaid pay services (Age = 65-74) (knowns ) {RCC SU 2018 PUF} Used Medicaid pay services (Age = 75-84) (knowns ) {RCC SU 2018 PUF} Used Medicaid pay services (Age = 85 ) (knowns ) {RCC SU 2018 PUF} Note according NCHS presentation criteria, percentages suppressed.","code":"tab(\"medicaid2\") tab(\"medicaid2\", drop_na = TRUE) tab_subset(\"medicaid2\", \"Age\", drop_na = TRUE)"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report.html","id":"figure-4","dir":"Articles","previous_headings":"","what":"Figure 4","title":"Example: Residential Care Community Services User (NSLTCP RCC SU) report","text":"(Figure 3 slightly involved, ’ll next.) figure shows percentage residents one select set chronic conditions. addition, shows distribution residents number conditions. ’s table high blood pressure. Resident diagnosed high blood pressure {RCC SU 2018 PUF} , unknown values (NA) present, figure based knowns . Therefore, use drop_na argument: Resident diagnosed high blood pressure (knowns ) {RCC SU 2018 PUF} Resident diagnosed Alzheimer’s/dementia (knowns ) {RCC SU 2018 PUF} Resident diagnosed depression (knowns ) {RCC SU 2018 PUF} Resident diagnosed arthritis (knowns ) {RCC SU 2018 PUF} Resident diagnosed diabetes (knowns ) {RCC SU 2018 PUF} Resident diagnosed heart disease (knowns ) {RCC SU 2018 PUF} Resident diagnosed osteoporosis (knowns ) {RCC SU 2018 PUF} Resident diagnosed COPD (knowns ) {RCC SU 2018 PUF} Resident diagnosed stroke (knowns ) {RCC SU 2018 PUF} Resident diagnosed cancer (knowns ) {RCC SU 2018 PUF}","code":"tab(\"hbp\") tab(\"hbp\", \"alz\", \"depress\", \"arth\", \"diabetes\", \"heartdise\", \"osteo\"     , \"copd\", \"stroke\", \"cancer\"     , drop_na = TRUE)"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report.html","id":"advanced-variable-editing","dir":"Articles","previous_headings":"Figure 4","what":"Advanced variable editing","title":"Example: Residential Care Community Services User (NSLTCP RCC SU) report","text":"surveytable provides number functions create modify survey variables. saw couple : var_collapse() var_cut(). Occasionally, might need advanced variable editing. ’s : Every survey object element called variables data frame survey’s variables located Create new variable variables data frame (part survey object). Call set_survey() . time modify variables data frame, call set_survey(). Tabulate new variable. go steps count many chronic conditions present. Survey info {RCC SU 2018 PUF} num_cc numeric variable number chronic conditions. published figure uses categorical variable based numeric variable. Use var_cut(), converts numeric variables categorical (factor) variables. Number chronic conditions {RCC SU 2018 PUF}","code":"class(rccsu2018$variables) ## [1] \"data.frame\" rccsu2018$variables$num_cc = 0 for (vr in c(\"hbp\", \"alz\", \"depress\", \"arth\", \"diabetes\", \"heartdise\", \"osteo\"              , \"copd\", \"stroke\", \"cancer\")) {   idx = which(rccsu2018$variables[,vr])   rccsu2018$variables$num_cc[idx] = rccsu2018$variables$num_cc[idx] + 1 } set_survey(rccsu2018, mode = \"NCHS\") ## * Mode: NCHS. var_cut(\"Number of chronic conditions\", \"num_cc\"         , c(-Inf, 0, 1, 3, 10, Inf)         , c(\"0\", \"1\", \"2-3\", \"4-10\", \"??\")) tab(\"Number of chronic conditions\")"},{"path":"https://cdcgov.github.io/surveytable/articles/Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report.html","id":"figure-3","dir":"Articles","previous_headings":"","what":"Figure 3","title":"Example: Residential Care Community Services User (NSLTCP RCC SU) report","text":"figure shows percentage residents need help one activities daily living (ADLs). addition, shows distribution residents number ADLs need help. ’s table bathhlp (help bathing): Type assistance resident needs bathe {RCC SU 2018 PUF} variable multiple levels. Several levels correspond resident needing help, One level (\"NEED ASSISTANCE\") = need help One level (\"MISSING\") = unknown want show (resident needing help) percentage knowns (, excluding unknowns). , convert variable 2 levels (needs help / need help) plus NA (unknown); use drop_na argument base percentages knowns . Type assistance resident needs bathe (knowns ) {RCC SU 2018 PUF} Type assistance resident needs locomotion (knowns ) {RCC SU 2018 PUF} Type assistance resident needs dress (knowns ) {RCC SU 2018 PUF} Type assistance resident needs transfer /chair (knowns ) {RCC SU 2018 PUF} Type assistance resident needs use bathroom (knowns ) {RCC SU 2018 PUF} Type assistance resident needs eat (knowns ) {RCC SU 2018 PUF} Now, go “advanced variable editing” steps – similar Figure 4 – count many ADLs present. Survey info {RCC SU 2018 PUF} generating figure, create categorical variable based num_adl, numeric. Number ADLs {RCC SU 2018 PUF}","code":"tab(\"bathhlp\") for (vr in c(\"bathhlp\", \"walkhlp\", \"dreshlp\", \"transhlp\", \"toilhlp\", \"eathlp\")) {   var_collapse(vr     , \"Needs assistance\"     , c(\"NEED HELP OR SUPERVISION FROM ANOTHER PERSON\"       , \"USE OF AN ASSISTIVE DEVICE\"       , \"BOTH\"))   var_collapse(vr, NA, \"MISSING\") }  tab(\"bathhlp\", \"walkhlp\", \"dreshlp\", \"transhlp\", \"toilhlp\", \"eathlp\", drop_na = TRUE) rccsu2018$variables$num_adl = 0 for (vr in c(\"bathhlp\", \"walkhlp\", \"dreshlp\", \"transhlp\", \"toilhlp\", \"eathlp\")) {   idx = which(rccsu2018$variables[,vr] %in%     c(\"NEED HELP OR SUPERVISION FROM ANOTHER PERSON\"       , \"USE OF AN ASSISTIVE DEVICE\"       , \"BOTH\"))   rccsu2018$variables$num_adl[idx] = rccsu2018$variables$num_adl[idx] + 1 } set_survey(rccsu2018, mode = \"NCHS\") ## * Mode: NCHS. var_cut(\"Number of ADLs\", \"num_adl\"         , c(-Inf, 0, 2, 6, Inf)         , c(\"0\", \"1-2\", \"3-6\", \"??\")) tab(\"Number of ADLs\")"},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"concepts","dir":"Articles","previous_headings":"Preliminaries","what":"Concepts","title":"Introduction to surveytable","text":"two important concepts need learn distinguish: data frame standard way storing data R. data frame rectangular data. Variables columns, observations rows. Example: data frame, , represent complex survey. , just looking data frame, R know sampling weights , strata , etc. Even variables represent sampling weights, etc, part data frame, just looking data frame, R know variable represents weights survey design variables. can get data frame R many different ways. data currently comma-separated values (CSV) file, can use read.csv(). ’s SAS file, can use package like haven importsurvey. ’s already R format, use readRDS(), . survey object object describes survey. tells R sampling weights , strata , . data frame can converted survey object using survey::svydesign() function; survey uses replicate weights, survey::svrepdesign() function used. Generally speaking, need convert data frame survey object . converted, can save saveRDS() (similar). future, can load readRDS(). need re-convert data frame survey object every time.","code":"head(iris) #>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> 1          5.1         3.5          1.4         0.2  setosa #> 2          4.9         3.0          1.4         0.2  setosa #> 3          4.7         3.2          1.3         0.2  setosa #> 4          4.6         3.1          1.5         0.2  setosa #> 5          5.0         3.6          1.4         0.2  setosa #> 6          5.4         3.9          1.7         0.4  setosa"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"namcs","dir":"Articles","previous_headings":"Preliminaries","what":"NAMCS","title":"Introduction to surveytable","text":"Examples tutorial use survey called National Ambulatory Medical Care Survey (NAMCS) 2019 Public Use File (PUF). NAMCS “annual nationally representative sample survey visits non-federal office-based patient care physicians, excluding anesthesiologists, radiologists, pathologists.” Note unit observation visits, patients – distinction important since single patient can make multiple visits. surveytable package comes data frame selected variables NAMCS, called namcs2019sv_df (sv = selected variables; df = data frame). survey object survey called namcs2019sv. namcs2019sv object analyze. really need namcs2019sv. reason package namcs2019sv_df illustrate convert data frame survey object.","code":""},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"more-concepts","dir":"Articles","previous_headings":"Preliminaries","what":"More concepts","title":"Introduction to surveytable","text":"importing data another source, SAS CSV, analysts aware standard way variables handled R. Specifically, categorical variables stored factor. true / false variables stored factor well, programming tasks easier stored logical. Unknown values stored missing (NA). variable contains “special values”, negative value indicating age missing, “special values” need converted NA. Variables namcs2019sv_df already stored correctly. Thus, AGER (patient’s age group) factor variable; PAYNOCHG (indicates whether charge physician visit) logical variable; AGE (patient’s age years) numeric variable.","code":"library(\"surveytable\") class(namcs2019sv_df$AGER) #> [1] \"factor\" class(namcs2019sv_df$PAYNOCHG) #> [1] \"logical\" class(namcs2019sv_df$AGE) #> [1] \"numeric\""},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"create-a-survey-object","dir":"Articles","previous_headings":"Preliminaries","what":"Create a survey object","title":"Introduction to surveytable","text":"seen , tables produced surveytable clearer either variable names descriptive, variables \"label\" attribute descriptive. namcs2019sv_df, variables already \"label\" attribute set. example, variable name AGE descriptive, variable descriptive \"label\" attribute: Documentation NAMCS survey provides names survey design variables. Specifically, NAMCS, cluster ID’s, also known primary sampling units (PSU’s), given CPSUM; strata given CSTRATM; sampling weights given PATWT. Thus, namcs2019sv_df data frame can turned survey object follows: Tables produced surveytable clearer either name survey object descriptive, object \"label\" attribute descriptive. Let’s set attribute mysurvey: mysurvey object now namcs2019sv. Let’s verify : just successfully created survey object data frame.","code":"attr(namcs2019sv_df$AGE, \"label\") #> [1] \"Patient age in years (raw - use caution)\" mysurvey = survey::svydesign(ids = ~ CPSUM   , strata = ~ CSTRATM   , weights = ~ PATWT   , data = namcs2019sv_df) attr(mysurvey, \"label\") = \"NAMCS 2019 PUF\" all.equal(namcs2019sv, mysurvey) #> [1] TRUE"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"begin-analysis","dir":"Articles","previous_headings":"","what":"Begin analysis","title":"Introduction to surveytable","text":"First, specify survey object ’d like analyze. Survey info {NAMCS 2019 PUF} Check survey label, survey design variables, number observations verify looks correct. example, want turn certain NCHS-specific options, identifying low-precision estimates. care identifying low-precision estimates, can skip command. turn NCHS-specific options:","code":"set_survey(namcs2019sv) set_opts(mode = \"NCHS\") #> * Mode: NCHS."},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"list-variables","dir":"Articles","previous_headings":"Begin analysis","what":"List variables","title":"Introduction to surveytable","text":"var_list() function lists variables survey. avoid unintentionally listing variables survey, can many, starting characters variable names specified. example, list variables start letters age, type: Variables beginning ‘age’ {NAMCS 2019 PUF} table lists variable name; class, type variable; variable label, long name variable. Common classes factor (categorical variable), logical (yes / variable), numeric.","code":"var_list(\"age\")"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"tabulate-categorical-and-logical-variables","dir":"Articles","previous_headings":"","what":"Tabulate categorical and logical variables","title":"Introduction to surveytable","text":"main function surveytable package tab(), tabulates variables. operates categorical logical variables, presents estimated counts, standard errors (SEs) 95% confidence intervals (CIs), percentages, SEs CIs. example, tabulate AGER, type: Patient age recode {NAMCS 2019 PUF} table title shows variable label (long variable name) survey label. level variable, table shows: estimated count, standard error, 95% confidence interval; estimated percentage, standard error, 95% confidence interval. Low-precision estimates. Optionally, tab() function, well tabulation functions discussed , can automatically identify low-precision estimates using algorithms developed NCHS. counts, rates, percentages, functions flag estimates , according algorithms, presented, reviewed clearance official, presented footnote. estimates flagged checks, table footnote indicates . checks identify estimate, denoted additional column table footnote. Turn functionality using following: set_opts(lpe = TRUE), set_opts(mode = \"nchs\"), set_survey(*, mode = \"nchs\"), options(surveytable.find_lpe = TRUE). example, let’s tabulate PAYNOCHG: Expected source payment visit: Charge/Charity {NAMCS 2019 PUF} table tells us estimated number visits charge visit low precision. Intuitively, can see CI count estimate wide, indicating high uncertainty. CIs displayed ones used NCHS presentation standards. Specifically, counts, tables show log Student’s t 95% CI, adaptations complex surveys; percentages, show 95% Korn Graubard CI. Drop missing values. variables might contain missing values (NA). Consider following variable, part actual survey, constructed specifically example: Type specialty (BAD - use) {NAMCS 2019 PUF} calculate percentages based non-missing values , use drop_na argument: Type specialty (BAD - use) (knowns ) {NAMCS 2019 PUF} table gives percentages based knowns, , based non-NA values. Multiple tables. Multiple tables can created single command: Type doctor (MD ) {NAMCS 2019 PUF} Type specialty (Primary, Medical, Surgical) {NAMCS 2019 PUF} Metropolitan Statistical Area Status physician location {NAMCS 2019 PUF}","code":"tab(\"AGER\") tab(\"PAYNOCHG\") tab(\"SPECCAT.bad\") tab(\"SPECCAT.bad\", drop_na = TRUE) tab(\"MDDO\", \"SPECCAT\", \"MSA\")"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"entire-population","dir":"Articles","previous_headings":"Tabulate categorical and logical variables","what":"Entire population","title":"Introduction to surveytable","text":"Estimate total count entire population using total() command: Total {NAMCS 2019 PUF}","code":"total()"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"subsets-or-interactions","dir":"Articles","previous_headings":"Tabulate categorical and logical variables","what":"Subsets or interactions","title":"Introduction to surveytable","text":"create table AGER value variable SEX, type: Patient age recode (Patient sex = Female) {NAMCS 2019 PUF} Patient age recode (Patient sex = Male) {NAMCS 2019 PUF} addition giving long name variable tabulated, title table reflects value subsetting variable (case, either Female Male). tab_subset() command, table (, subset), percentages add 100%. tab_cross() function similar – crosses interacts two variables generates table using new variable. Thus, create table interaction AGER SEX, type: (Patient age recode) x (Patient sex) {NAMCS 2019 PUF} estimated counts produced tab_subset() tab_cross() , percentages different. tab_subset() command, within table (, within subset), percentages add 100%. hand, tab_cross(), percentages across entire population add 100%.","code":"tab_subset(\"AGER\", \"SEX\") tab_cross(\"AGER\", \"SEX\")"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"tabulate-numeric-variables","dir":"Articles","previous_headings":"","what":"Tabulate numeric variables","title":"Introduction to surveytable","text":"tab() tab_subset() functions also work numeric variables, though variables, output different. tabulate NUMMED (number medications), numeric variable, type: Number medications coded {NAMCS 2019 PUF} , table title shows variable label (long variable name) survey label. table shows percentage values missing (NA), mean, standard error mean (SEM), standard deviation (SD). Subsetting works : Number medications coded (different levels Patient age recode) {NAMCS 2019 PUF}","code":"tab(\"NUMMED\") tab_subset(\"NUMMED\", \"AGER\")"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"perform-statistical-hypothesis-testing","dir":"Articles","previous_headings":"","what":"Perform statistical hypothesis testing","title":"Introduction to surveytable","text":"tab_subset() function makes easy perform hypothesis testing using test argument. argument TRUE, test association performed. addition, t-tests pairs levels performed well.","code":""},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"categorical-variables","dir":"Articles","previous_headings":"Perform statistical hypothesis testing","what":"Categorical variables","title":"Introduction to surveytable","text":"Consider relationship AGER SPECCAT: Patient age recode (Type specialty (Primary, Medical, Surgical) = Primary care specialty) {NAMCS 2019 PUF} Patient age recode (Type specialty (Primary, Medical, Surgical) = Surgical care specialty) {NAMCS 2019 PUF} Patient age recode (Type specialty (Primary, Medical, Surgical) = Medical care specialty) {NAMCS 2019 PUF} Association Patient age recode Type specialty (Primary, Medical, Surgical) {NAMCS 2019 PUF} Comparison possible pairs Patient age recode (Type specialty (Primary, Medical, Surgical) = Primary care specialty) {NAMCS 2019 PUF} Comparison possible pairs Patient age recode (Type specialty (Primary, Medical, Surgical) = Surgical care specialty) {NAMCS 2019 PUF} Comparison possible pairs Patient age recode (Type specialty (Primary, Medical, Surgical) = Medical care specialty) {NAMCS 2019 PUF} Comparison possible pairs Type specialty (Primary, Medical, Surgical) (Patient age recode = 15 years) {NAMCS 2019 PUF} Comparison possible pairs Type specialty (Primary, Medical, Surgical) (Patient age recode = 15-24 years) {NAMCS 2019 PUF} Comparison possible pairs Type specialty (Primary, Medical, Surgical) (Patient age recode = 25-44 years) {NAMCS 2019 PUF} Comparison possible pairs Type specialty (Primary, Medical, Surgical) (Patient age recode = 45-64 years) {NAMCS 2019 PUF} Comparison possible pairs Type specialty (Primary, Medical, Surgical) (Patient age recode = 65-74 years) {NAMCS 2019 PUF} Comparison possible pairs Type specialty (Primary, Medical, Surgical) (Patient age recode = 75 years ) {NAMCS 2019 PUF} According tables, association physician specialty type patient age. instance, patients 15 years, statistical difference primary care physician specialty medical care specialty. older patients, 45-64 age group, statistical difference two specialty types. another example, consider relationship MRI SPECCAT: MRI (Type specialty (Primary, Medical, Surgical) = Primary care specialty) {NAMCS 2019 PUF} MRI (Type specialty (Primary, Medical, Surgical) = Surgical care specialty) {NAMCS 2019 PUF} MRI (Type specialty (Primary, Medical, Surgical) = Medical care specialty) {NAMCS 2019 PUF} Association MRI Type specialty (Primary, Medical, Surgical) {NAMCS 2019 PUF} Comparison possible pairs MRI (Type specialty (Primary, Medical, Surgical) = Primary care specialty) {NAMCS 2019 PUF} Comparison possible pairs MRI (Type specialty (Primary, Medical, Surgical) = Surgical care specialty) {NAMCS 2019 PUF} Comparison possible pairs MRI (Type specialty (Primary, Medical, Surgical) = Medical care specialty) {NAMCS 2019 PUF} Comparison possible pairs Type specialty (Primary, Medical, Surgical) (MRI = FALSE) {NAMCS 2019 PUF} Comparison possible pairs Type specialty (Primary, Medical, Surgical) (MRI = TRUE) {NAMCS 2019 PUF} According tables, statistical association MRI physician specialty. 3 specialty types, minority visits MRI’s. visits MRI’s, statistical difference specialty types. general rule thumb, since statistical association MRI physician specialty, presenting tabulation particularly interesting, especially since subsetting decreases sample size therefore also decreases estimate reliability. Instead, generally make sense just tabulate MRI without subsetting SPECCAT.","code":"tab_subset(\"AGER\", \"SPECCAT\", test = TRUE) tab_subset(\"MRI\", \"SPECCAT\", test = TRUE)"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"numeric-variables","dir":"Articles","previous_headings":"Perform statistical hypothesis testing","what":"Numeric variables","title":"Introduction to surveytable","text":"relationship NUMMED AGER: Number medications coded (different levels Patient age recode) {NAMCS 2019 PUF} Association Number medications coded Patient age recode {NAMCS 2019 PUF} Comparison Number medications coded across possible pairs Patient age recode {NAMCS 2019 PUF} According tables, association number medications age category. NUMMED statistically similar “15 years” “15-24 years” AGER categories. statistically different pairs age categories. Finally, let’s look relationship NUMMED SPECCAT: Number medications coded (different levels Type specialty (Primary, Medical, Surgical)) {NAMCS 2019 PUF} Association Number medications coded Type specialty (Primary, Medical, Surgical) {NAMCS 2019 PUF} Comparison Number medications coded across possible pairs Type specialty (Primary, Medical, Surgical) {NAMCS 2019 PUF} According tables, association number medications physician specialty type. NUMMED statistically similar pairs physician specialties. general rule thumb, since statistical association number medications physician specialty, presenting tabulation particularly interesting, especially since subsetting decreases sample size therefore also decreases estimate reliability. Instead, generally make sense just tabulate NUMMED without subsetting SPECCAT.","code":"tab_subset(\"NUMMED\", \"AGER\", test = TRUE) tab_subset(\"NUMMED\", \"SPECCAT\", test = TRUE)"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"categorical-variables-single-variable","dir":"Articles","previous_headings":"Perform statistical hypothesis testing","what":"Categorical variables (single variable)","title":"Introduction to surveytable","text":"test whether pair SPECCAT levels statistically similar different, type: Type specialty (Primary, Medical, Surgical) {NAMCS 2019 PUF} Comparison possible pairs Type specialty (Primary, Medical, Surgical) {NAMCS 2019 PUF} According , surgical medical care specialties statistically similar, statistically different primary care.","code":"tab(\"SPECCAT\", test = TRUE)"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"calculate-rates","dir":"Articles","previous_headings":"","what":"Calculate rates","title":"Introduction to surveytable","text":"rate ratio count estimates based survey question divided population size, assumed known. example, number physician visits per 100 people population rate: number physician visits estimated namcs2019sv survey, number people population comes another source. calculate rates, addition survey, need source information population size. typically use function read.csv() load population figures get correct format. surveytable package comes object called uspop2019 contains several population figures use examples. Let’s examine uspop2019: overall population size country whole : overall population size, overall rate : Total (rate per 100 population) {NAMCS 2019 PUF} calculate rates particular variable, need provide data frame column called Level matches levels variable survey, column called Population gives size population level. example, AGER, data frame follows: Now appropriate population figures, rates table obtained typing: Patient age recode (rate per 100 population) {NAMCS 2019 PUF} calculate rates one variable (AGER) another variable (SEX), need population figures following format: data frame, rates table obtained typing: Patient age recode (Patient sex = Female) (rate per 100 population) {NAMCS 2019 PUF} Patient age recode (Patient sex = Male) (rate per 100 population) {NAMCS 2019 PUF}","code":"class(uspop2019) #> [1] \"list\" names(uspop2019) #> [1] \"total\"       \"MSA\"         \"AGER\"        \"Age group\"   \"SEX\"         #> [6] \"AGER x SEX\"  \"Age group 5\" uspop2019$total #> [1] 323186697 total_rate(uspop2019$total) uspop2019$AGER #>               Level Population #> 1    Under 15 years   60526656 #> 2       15-24 years   41718700 #> 3       25-44 years   85599410 #> 4       45-64 years   82562049 #> 5       65-74 years   31260202 #> 6 75 years and over   21519680 tab_rate(\"AGER\", uspop2019$AGER) uspop2019$`AGER x SEX` #>                Level Subset Population #> 1     Under 15 years Female   29604762 #> 2        15-24 years Female   20730118 #> 3        25-44 years Female   43192143 #> 4        45-64 years Female   42508901 #> 5        65-74 years Female   16673240 #> 6  75 years and over Female   12421444 #> 7     Under 15 years   Male   30921894 #> 8        15-24 years   Male   20988582 #> 9        25-44 years   Male   42407267 #> 10       45-64 years   Male   40053148 #> 11       65-74 years   Male   14586962 #> 12 75 years and over   Male    9098236 tab_subset_rate(\"AGER\", \"SEX\", uspop2019$`AGER x SEX`)"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"create-or-modify-variables","dir":"Articles","previous_headings":"","what":"Create or modify variables","title":"Introduction to surveytable","text":"situations, might necessary modify survey variables, create new ones. section describes . Convert factor logical. variable MAJOR (major reason visit) several levels. Major reason visit {NAMCS 2019 PUF} Notice one levels called \"Preventive care\". Suppose analyst interested whether visit preventive care visit – interested visit types. can create new variable called Preventive care visits TRUE preventive care visits FALSE types visits, follows: Preventive care visits {NAMCS 2019 PUF} creates logical variable TRUE preventive care visits tabulates . using var_case() function, specify name new logical variable created, existing factor variable, one levels factor variable set TRUE logical variable. Thus, analyst interested surgery-related visits, indicated two different levels MAJOR, type: Surgery-related visits {NAMCS 2019 PUF} Collapse levels. variable PRIMCARE (whether physician patient’s primary care provider) levels Unknown Blank, among others. patient’s primary care provider? {NAMCS 2019 PUF} collapse Unknown Blank single level, type: patient’s primary care provider? {NAMCS 2019 PUF} Convert numeric factor. variable AGE numeric. Patient age years (raw - use caution) {NAMCS 2019 PUF} create new variable age categories based AGE, type: Age group {NAMCS 2019 PUF} var_cut() command, specify following information: name new categorical variable; name existing numeric variable; cut points – note intervals inclusive right; category labels. cognizant “special values” numeric variable might . data systems, negative values indicate unknowns, coded NA. ’s – value -Inf -0.1 gets coded missing (NA). Though particular data, unknowns “special values”. Check whether variable true. series logical variables, can check whether TRUE using var_any() command. physician visit considered “imaging services” visit number imaging services ordered provided. Imaging services indicated using logical variables, MRI XRAY. create Imaging services variable, type: Imaging services {NAMCS 2019 PUF} Interact variables. tab_cross() function creates table interaction two variables, save interacted variable. create interacted variable, use var_cross() command: Specify name new variable well names two variables interact. Copy variable. Create new variable copy another variable using var_copy(). can modify copy, original remains unchanged. example: Patient age recode {NAMCS 2019 PUF} Age group {NAMCS 2019 PUF} , AGER variable remains unchanged, Age group variable fewer categories.","code":"tab(\"MAJOR\") var_case(\"Preventive care visits\", \"MAJOR\", \"Preventive care\") tab(\"Preventive care visits\") var_case(\"Surgery-related visits\"   , \"MAJOR\"   , c(\"Pre-surgery\", \"Post-surgery\")) tab(\"Surgery-related visits\") tab(\"PRIMCARE\") var_collapse(\"PRIMCARE\", \"Unknown if PCP\", c(\"Unknown\", \"Blank\")) tab(\"PRIMCARE\") tab(\"AGE\") var_cut(\"Age group\"    , \"AGE\"    , c(-Inf, -0.1, 0, 4, 14, 64, Inf)    , c(NA, \"Under 1\", \"1-4\", \"5-14\", \"15-64\", \"65 and over\")) tab(\"Age group\") var_any(\"Imaging services\"   , c(\"ANYIMAGE\", \"BONEDENS\", \"CATSCAN\", \"ECHOCARD\", \"OTHULTRA\"   , \"MAMMO\", \"MRI\", \"XRAY\", \"OTHIMAGE\")) tab(\"Imaging services\") var_cross(\"Age x Sex\", \"AGER\", \"SEX\") var_copy(\"Age group\", \"AGER\") #> Warning in var_copy(\"Age group\", \"AGER\"): Age group: overwriting a variable #> that already exists. var_collapse(\"Age group\", \"65+\", c(\"65-74 years\", \"75 years and over\")) var_collapse(\"Age group\", \"25-64\", c(\"25-44 years\", \"45-64 years\")) tab(\"AGER\", \"Age group\")"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"save-the-output","dir":"Articles","previous_headings":"","what":"Save the output","title":"Introduction to surveytable","text":"tab* total* functions argument called csv specifies name comma-separated values (CSV) file save output . Alternatively, can name default CSV output file using set_opts() function. example, following directs surveytable send future output CSV file, create tables, turn sending output file: Type doctor (MD ) {NAMCS 2019 PUF} tabulation functions called within R Markdown notebook Quarto document, produce HTML LaTeX tables, appropriate. makes easy incorporate output surveytable package directly documents, presentations, “shiny” web apps, output types. Finally, tabulation functions return tables produce. advanced analysts can use functionality integrate surveytable programming tasks.","code":"set_opts(csv = \"output.csv\") tab(\"MDDO\") set_opts(csv = \"\") #> * Turning off CSV output."},{"path":"https://cdcgov.github.io/surveytable/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Alex Strashny. Author, maintainer.","code":""},{"path":"https://cdcgov.github.io/surveytable/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Strashny (2023). surveytable: Formatted Survey Estimates. doi:10.32614/CRAN.package.surveytable, https://cdcgov.github.io/surveytable/.","code":"@Manual{,   title = {surveytable: Formatted Survey Estimates},   author = {Alex Strashny},   year = {2023},   url = {https://cdcgov.github.io/surveytable/},   doi = {10.32614/CRAN.package.surveytable}, }"},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"survey-table-formatted-survey-estimates","dir":"","previous_headings":"","what":"Formatted Survey Estimates","title":"Formatted Survey Estimates","text":"surveytable R package conveniently tabulating estimates complex surveys. deal survey objects R (created survey::svydesign()), package . Works complex surveys (data systems involve survey design variables, like weights strata). Works unweighted data well. surveytable package provides short understandable commands generate tabulated, formatted, rounded survey estimates. surveytable, can tabulate estimated counts percentages, standard errors confidence intervals, estimate total population, tabulate survey subsets variable interactions, tabulate numeric variables, perform hypothesis tests, tabulate rates, modify survey variables, save output. Optionally, tabulation functions can identify low-precision estimates using National Center Health Statistics (NCHS) algorithms (algorithms). surveytable code called R Markdown notebook Quarto document, automatically generates HTML LaTeX tables, appropriate. package reduces number commands users need execute, especially helpful users new R programming.","code":""},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Formatted Survey Estimates","text":"Install CRAN: get development version GitHub:","code":"install.packages(\"surveytable\") install.packages(c(\"remotes\", \"git2r\")) remotes::install_github(\"CDCgov/surveytable\", upgrade = \"never\")"},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"documentation","dir":"","previous_headings":"","what":"Documentation","title":"Formatted Survey Estimates","text":"Find documentation surveytable : https://cdcgov.github.io/surveytable/","code":""},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"example","dir":"","previous_headings":"","what":"Example","title":"Formatted Survey Estimates","text":"basic example, get started. Load package: Specify survey wish analyze. surveytable comes survey called namcs2019sv, use examples. Survey info {NAMCS 2019 PUF} Specify variable analyze. NAMCS, AGER age category variable: Patient age recode {NAMCS 2019 PUF} table shows: Descriptive variable name Survey name Number observations Estimated count SE 95% CI Estimated percentage SE 95% CI Sample size Optionally, table can show whether low-precision estimates found","code":"library(surveytable) set_survey(namcs2019sv) tab(\"AGER\")"},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"public-domain-standard-notice","dir":"","previous_headings":"","what":"Public Domain Standard Notice","title":"Formatted Survey Estimates","text":"repository constitutes work United States Government subject domestic copyright protection 17 USC § 105. repository public domain within United States, copyright related rights work worldwide waived CC0 1.0 Universal public domain dedication. contributions repository released CC0 dedication. submitting pull request agreeing comply waiver copyright interest.","code":""},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"license-standard-notice","dir":"","previous_headings":"","what":"License Standard Notice","title":"Formatted Survey Estimates","text":"repository utilizes code licensed terms Apache Software License therefore licensed ASL v2 later. source code repository free: can redistribute /modify terms Apache Software License version 2, (option) later version. source code repository distributed hope useful, WITHOUT WARRANTY; without even implied warranty MERCHANTABILITY FITNESS PARTICULAR PURPOSE. See Apache Software License details. received copy Apache Software License along program. , see https://www.apache.org/licenses/LICENSE-2.0.html source code forked open source projects inherit license.","code":""},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"privacy-standard-notice","dir":"","previous_headings":"","what":"Privacy Standard Notice","title":"Formatted Survey Estimates","text":"repository contains non-sensitive, publicly available data information. material community participation covered Disclaimer Code Conduct. information CDC’s privacy policy, please visit https://www.cdc.gov//privacy.html.","code":""},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"contributing-standard-notice","dir":"","previous_headings":"","what":"Contributing Standard Notice","title":"Formatted Survey Estimates","text":"Anyone encouraged contribute repository forking submitting pull request. (new GitHub, might start basic tutorial.) contributing project, grant world-wide, royalty-free, perpetual, irrevocable, non-exclusive, transferable license users terms Apache Software License v2 later. comments, messages, pull requests, submissions received CDC including GitHub page may subject applicable federal law, including limited Federal Records Act, may archived. Learn https://www.cdc.gov//privacy.html.","code":""},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"records-management-standard-notice","dir":"","previous_headings":"","what":"Records Management Standard Notice","title":"Formatted Survey Estimates","text":"repository source government records, copy increase collaboration collaborative potential. government records published CDC web site.","code":""},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"additional-standard-notices","dir":"","previous_headings":"","what":"Additional Standard Notices","title":"Formatted Survey Estimates","text":"Please refer CDC’s Template Repository information contributing repository, public domain notices disclaimers, code conduct.","code":""},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"Apache License","title":"Apache License","text":"Version 2.0, January 2004 ","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":"id_1-definitions","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"1. Definitions","title":"Apache License","text":"“License” shall mean terms conditions use, reproduction, distribution defined Sections 1 9 document. “Licensor” shall mean copyright owner entity authorized copyright owner granting License. “Legal Entity” shall mean union acting entity entities control, controlled , common control entity. purposes definition, “control” means () power, direct indirect, cause direction management entity, whether contract otherwise, (ii) ownership fifty percent (50%) outstanding shares, (iii) beneficial ownership entity. “” (“”) shall mean individual Legal Entity exercising permissions granted License. “Source” form shall mean preferred form making modifications, including limited software source code, documentation source, configuration files. “Object” form shall mean form resulting mechanical transformation translation Source form, including limited compiled object code, generated documentation, conversions media types. “Work” shall mean work authorship, whether Source Object form, made available License, indicated copyright notice included attached work (example provided Appendix ). “Derivative Works” shall mean work, whether Source Object form, based (derived ) Work editorial revisions, annotations, elaborations, modifications represent, whole, original work authorship. purposes License, Derivative Works shall include works remain separable , merely link (bind name) interfaces , Work Derivative Works thereof. “Contribution” shall mean work authorship, including original version Work modifications additions Work Derivative Works thereof, intentionally submitted Licensor inclusion Work copyright owner individual Legal Entity authorized submit behalf copyright owner. purposes definition, “submitted” means form electronic, verbal, written communication sent Licensor representatives, including limited communication electronic mailing lists, source code control systems, issue tracking systems managed , behalf , Licensor purpose discussing improving Work, excluding communication conspicuously marked otherwise designated writing copyright owner “Contribution.” “Contributor” shall mean Licensor individual Legal Entity behalf Contribution received Licensor subsequently incorporated within Work.","code":""},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":"id_2-grant-of-copyright-license","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"2. Grant of Copyright License","title":"Apache License","text":"Subject terms conditions License, Contributor hereby grants perpetual, worldwide, non-exclusive, -charge, royalty-free, irrevocable copyright license reproduce, prepare Derivative Works , publicly display, publicly perform, sublicense, distribute Work Derivative Works Source Object form.","code":""},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":"id_3-grant-of-patent-license","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"3. Grant of Patent License","title":"Apache License","text":"Subject terms conditions License, Contributor hereby grants perpetual, worldwide, non-exclusive, -charge, royalty-free, irrevocable (except stated section) patent license make, made, use, offer sell, sell, import, otherwise transfer Work, license applies patent claims licensable Contributor necessarily infringed Contribution(s) alone combination Contribution(s) Work Contribution(s) submitted. institute patent litigation entity (including cross-claim counterclaim lawsuit) alleging Work Contribution incorporated within Work constitutes direct contributory patent infringement, patent licenses granted License Work shall terminate date litigation filed.","code":""},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":"id_4-redistribution","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"4. Redistribution","title":"Apache License","text":"may reproduce distribute copies Work Derivative Works thereof medium, without modifications, Source Object form, provided meet following conditions: () must give recipients Work Derivative Works copy License; (b) must cause modified files carry prominent notices stating changed files; (c) must retain, Source form Derivative Works distribute, copyright, patent, trademark, attribution notices Source form Work, excluding notices pertain part Derivative Works; (d) Work includes “NOTICE” text file part distribution, Derivative Works distribute must include readable copy attribution notices contained within NOTICE file, excluding notices pertain part Derivative Works, least one following places: within NOTICE text file distributed part Derivative Works; within Source form documentation, provided along Derivative Works; , within display generated Derivative Works, wherever third-party notices normally appear. contents NOTICE file informational purposes modify License. may add attribution notices within Derivative Works distribute, alongside addendum NOTICE text Work, provided additional attribution notices construed modifying License. may add copyright statement modifications may provide additional different license terms conditions use, reproduction, distribution modifications, Derivative Works whole, provided use, reproduction, distribution Work otherwise complies conditions stated License.","code":""},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":"id_5-submission-of-contributions","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"5. Submission of Contributions","title":"Apache License","text":"Unless explicitly state otherwise, Contribution intentionally submitted inclusion Work Licensor shall terms conditions License, without additional terms conditions. Notwithstanding , nothing herein shall supersede modify terms separate license agreement may executed Licensor regarding Contributions.","code":""},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":"id_6-trademarks","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"6. Trademarks","title":"Apache License","text":"License grant permission use trade names, trademarks, service marks, product names Licensor, except required reasonable customary use describing origin Work reproducing content NOTICE file.","code":""},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":"id_7-disclaimer-of-warranty","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"7. Disclaimer of Warranty","title":"Apache License","text":"Unless required applicable law agreed writing, Licensor provides Work (Contributor provides Contributions) “” BASIS, WITHOUT WARRANTIES CONDITIONS KIND, either express implied, including, without limitation, warranties conditions TITLE, NON-INFRINGEMENT, MERCHANTABILITY, FITNESS PARTICULAR PURPOSE. solely responsible determining appropriateness using redistributing Work assume risks associated exercise permissions License.","code":""},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":"id_8-limitation-of-liability","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"8. Limitation of Liability","title":"Apache License","text":"event legal theory, whether tort (including negligence), contract, otherwise, unless required applicable law (deliberate grossly negligent acts) agreed writing, shall Contributor liable damages, including direct, indirect, special, incidental, consequential damages character arising result License use inability use Work (including limited damages loss goodwill, work stoppage, computer failure malfunction, commercial damages losses), even Contributor advised possibility damages.","code":""},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":"id_9-accepting-warranty-or-additional-liability","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"9. Accepting Warranty or Additional Liability","title":"Apache License","text":"redistributing Work Derivative Works thereof, may choose offer, charge fee , acceptance support, warranty, indemnity, liability obligations /rights consistent License. However, accepting obligations, may act behalf sole responsibility, behalf Contributor, agree indemnify, defend, hold Contributor harmless liability incurred , claims asserted , Contributor reason accepting warranty additional liability. END TERMS CONDITIONS","code":""},{"path":"https://cdcgov.github.io/surveytable/LICENSE.html","id":"appendix-how-to-apply-the-apache-license-to-your-work","dir":"","previous_headings":"","what":"APPENDIX: How to apply the Apache License to your work","title":"Apache License","text":"apply Apache License work, attach following boilerplate notice, fields enclosed brackets [] replaced identifying information. (Don’t include brackets!) text enclosed appropriate comment syntax file format. also recommend file class name description purpose included “printed page” copyright notice easier identification within third-party archives.","code":"Copyright [yyyy] [name of copyright owner]  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at    http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License."},{"path":"https://cdcgov.github.io/surveytable/reference/codebook.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a codebook for the survey — codebook","title":"Create a codebook for the survey — codebook","text":"Create codebook survey","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/codebook.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a codebook for the survey — codebook","text":"","code":"codebook(all = FALSE, csv = getOption(\"surveytable.csv\"))"},{"path":"https://cdcgov.github.io/surveytable/reference/codebook.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a codebook for the survey — codebook","text":"tabulate variables? csv name CSV file","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/codebook.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a codebook for the survey — codebook","text":"list tables.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/codebook.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a codebook for the survey — codebook","text":"","code":"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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  codebook() #>                         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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  #>                                     Codebook {NAMCS 2019 PUF}                                      #> ┌──────────┬─────────────┬───────────────────────┬─────────┬─────────────┬───────────────────────┐ #> │ Item no. │ Variable    │ Description           │ Class   │ Missing (%) │ Values                │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │        1 │ CPSUM       │ Masked provider       │ numeric │           0 │ 100001 - 100398       │ #> │          │             │ marker                │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │        2 │ CSTRATM     │ Masked sampling       │ numeric │           0 │ 10119101 - 10419115   │ #> │          │             │ stratum from which    │         │             │                       │ #> │          │             │ provider was selected │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │        3 │ PATWT       │ Patient visit weight  │ numeric │           0 │ 7064.00718 -          │ #> │          │             │ used for national and │         │             │ 1120996.55599         │ #> │          │             │ subnational estimates │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │        4 │ MDDO        │ Type of doctor (MD or │ factor  │           0 │ M.D. - Doctor of      │ #> │          │             │ DO)                   │         │             │ Medicine, D.O. -      │ #> │          │             │                       │         │             │ Doctor of Osteopathy  │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │        5 │ SPECCAT     │ Type of specialty     │ factor  │           0 │ Primary care          │ #> │          │             │ (Primary, Medical,    │         │             │ specialty, Surgical   │ #> │          │             │ Surgical)             │         │             │ care specialty,       │ #> │          │             │                       │         │             │ Medical care          │ #> │          │             │                       │         │             │ specialty             │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │        6 │ MSA         │ Metropolitan          │ factor  │           0 │ MSA (Metropolitan     │ #> │          │             │ Statistical Area      │         │             │ Statistical Area),    │ #> │          │             │ Status of physician   │         │             │ Non-MSA               │ #> │          │             │ location              │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │        7 │ AGER        │ Patient age recode    │ factor  │           0 │ Under 15 years, 15-24 │ #> │          │             │                       │         │             │ years, 25-44 years,   │ #> │          │             │                       │         │             │ 45-64 years, 65-74    │ #> │          │             │                       │         │             │ years, 75 years and   │ #> │          │             │                       │         │             │ over                  │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │        8 │ SEX         │ Patient sex           │ factor  │           0 │ Female, Male          │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │        9 │ AGE         │ Patient age in years  │ numeric │           0 │ 0 - 94                │ #> │          │             │ (raw - use caution)   │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       10 │ NOPAY       │ Expected source of    │ factor  │           0 │ One or more           │ #> │          │             │ payment for visit: No │         │             │ categories marked, No │ #> │          │             │ answer to item        │         │             │ categories marked     │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       11 │ PAYPRIV     │ Expected source of    │ logical │           0 │                       │ #> │          │             │ payment for visit:    │         │             │                       │ #> │          │             │ Private insurance     │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       12 │ PAYMCARE    │ Expected source of    │ logical │           0 │                       │ #> │          │             │ payment for visit:    │         │             │                       │ #> │          │             │ Medicare              │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       13 │ PAYMCAID    │ Expected source of    │ logical │           0 │                       │ #> │          │             │ payment for visit:    │         │             │                       │ #> │          │             │ Medicaid or CHIP or   │         │             │                       │ #> │          │             │ other state-based     │         │             │                       │ #> │          │             │ program               │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       14 │ PAYWKCMP    │ Expected source of    │ logical │           0 │                       │ #> │          │             │ payment for visit:    │         │             │                       │ #> │          │             │ Workers Compensation  │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       15 │ PAYOTH      │ Expected source of    │ logical │           0 │                       │ #> │          │             │ payment for visit:    │         │             │                       │ #> │          │             │ Other                 │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       16 │ PAYDK       │ Expected source of    │ logical │           0 │                       │ #> │          │             │ payment for visit:    │         │             │                       │ #> │          │             │ Unknown               │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       17 │ PAYSELF     │ Expected source of    │ logical │           0 │                       │ #> │          │             │ payment for visit:    │         │             │                       │ #> │          │             │ Self-pay              │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       18 │ PAYNOCHG    │ Expected source of    │ logical │           0 │                       │ #> │          │             │ payment for visit: No │         │             │                       │ #> │          │             │ Charge/Charity        │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       19 │ PRIMCARE    │ Are you the patient's │ factor  │           0 │ Blank, Unknown, Yes,  │ #> │          │             │ primary care          │         │             │ No                    │ #> │          │             │ provider?             │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       20 │ REFER       │ Was patient referred  │ factor  │           0 │ Blank, Unknown, Not   │ #> │          │             │ for visit?            │         │             │ applicable, Yes, No   │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       21 │ SENBEFOR    │ Has this patient been │ factor  │           0 │ Yes, established      │ #> │          │             │ seen in your practice │         │             │ patient, No, new      │ #> │          │             │ before?               │         │             │ patient               │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       22 │ MAJOR       │ Major reason for this │ factor  │           0 │ Blank, New problem    │ #> │          │             │ visit                 │         │             │ (less than 3 mos.     │ #> │          │             │                       │         │             │ onset), Chronic       │ #> │          │             │                       │         │             │ problem, routine,     │ #> │          │             │                       │         │             │ Chronic problem,      │ #> │          │             │                       │         │             │ flare-up,             │ #> │          │             │                       │         │             │ Pre-surgery,          │ #> │          │             │                       │         │             │ Post-surgery,         │ #> │          │             │                       │         │             │ Preventive care       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       23 │ NUMMED      │ Number of medications │ numeric │           0 │ 0 - 30                │ #> │          │             │ coded                 │         │             │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       24 │ ANYIMAGE    │ Any imaging           │ logical │           0 │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       25 │ BONEDENS    │ Bone mineral density  │ logical │           0 │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       26 │ CATSCAN     │ CT Scan               │ logical │           0 │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       27 │ ECHOCARD    │ Echocardiogram        │ logical │           0 │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       28 │ OTHULTRA    │ Ultrasound            │ logical │           0 │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       29 │ MAMMO       │ Mammography           │ logical │           0 │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       30 │ MRI         │ MRI                   │ logical │           0 │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       31 │ XRAY        │ X-ray                 │ logical │           0 │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       32 │ OTHIMAGE    │ Other imaging         │ logical │           0 │                       │ #> ├──────────┼─────────────┼───────────────────────┼─────────┼─────────────┼───────────────────────┤ #> │       33 │ SPECCAT.bad │ Type of specialty     │ factor  │          20 │ Primary care          │ #> │          │             │ (BAD - do not use)    │         │             │ specialty, Surgical   │ #> │          │             │                       │         │             │ care specialty,       │ #> │          │             │                       │         │             │ Medical care          │ #> │          │             │                       │         │             │ specialty             │ #> └──────────┴─────────────┴───────────────────────┴─────────┴─────────────┴───────────────────────┘ #>"},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/deprecated.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Deprecated functions — deprecated","text":"","code":"set_mode(mode = \"general\")  set_count_1k()  set_count_int()  set_output(drop_na = NULL, max_levels = NULL, csv = NULL)"},{"path":"https://cdcgov.github.io/surveytable/reference/deprecated.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Deprecated functions — deprecated","text":"Use set_opts() instead following: set_mode(), set_count_1k(), set_count_int(), set_output().","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/namcs2019sv.html","id":null,"dir":"Reference","previous_headings":"","what":"Selected variables from the National Ambulatory Medical Care Survey (NAMCS) 2019 Public Use File (PUF) — namcs2019sv","title":"Selected variables from the National Ambulatory Medical Care Survey (NAMCS) 2019 Public Use File (PUF) — namcs2019sv","text":"Selected variables data system visits office-based physicians. Note unit observation visits, patients - distinction important since single patient can make multiple visits.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/namcs2019sv.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Selected variables from the National Ambulatory Medical Care Survey (NAMCS) 2019 Public Use File (PUF) — namcs2019sv","text":"","code":"namcs2019sv  namcs2019sv_df"},{"path":"https://cdcgov.github.io/surveytable/reference/namcs2019sv.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Selected variables from the National Ambulatory Medical Care Survey (NAMCS) 2019 Public Use File (PUF) — namcs2019sv","text":"object class survey.design2 (inherits survey.design) 8250 rows 33 columns. object class data.frame 8250 rows 33 columns.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/namcs2019sv.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Selected variables from the National Ambulatory Medical Care Survey (NAMCS) 2019 Public Use File (PUF) — namcs2019sv","text":"SAS data: https://ftp.cdc.gov/pub/Health_Statistics/NCHS/Dataset_Documentation/NAMCS/sas/namcs2019_sas.zip Survey design variables: https://ftp.cdc.gov/pub/Health_Statistics/NCHS/Dataset_Documentation/NAMCS/sas/readme2019-sas.txt SAS formats: https://ftp.cdc.gov/pub/Health_Statistics/NCHS/Dataset_Documentation/NAMCS/sas/nam19for.txt Documentation: https://ftp.cdc.gov/pub/Health_Statistics/NCHS/Dataset_Documentation/NAMCS/doc2019-508.pdf National Summary Tables: https://www.cdc.gov/nchs/data/ahcd/namcs_summary/2019-namcs-web-tables-508.pdf","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/namcs2019sv.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Selected variables from the National Ambulatory Medical Care Survey (NAMCS) 2019 Public Use File (PUF) — namcs2019sv","text":"namcs2019sv_df data frame. namcs2019sv survey object created namcs2019sv_df using survey::svydesign().","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/print.surveytable_table.html","id":null,"dir":"Reference","previous_headings":"","what":"Print surveytable tables — print.surveytable_table","title":"Print surveytable tables — print.surveytable_table","text":"Print surveytable tables","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/print.surveytable_table.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Print surveytable tables — print.surveytable_table","text":"","code":"# S3 method for surveytable_table print(x, .output = NULL, ...)  # S3 method for surveytable_list print(x, .output = NULL, ...)"},{"path":"https://cdcgov.github.io/surveytable/reference/print.surveytable_table.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Print surveytable tables — print.surveytable_table","text":"x object class surveytable_table surveytable_list. .output output type. NULL = auto-detect. ... ignored","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/print.surveytable_table.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Print surveytable tables — print.surveytable_table","text":"x invisibly.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/print.surveytable_table.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Print surveytable tables — print.surveytable_table","text":"","code":"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.                                                                                                  #>"},{"path":"https://cdcgov.github.io/surveytable/reference/rccsu2018.html","id":null,"dir":"Reference","previous_headings":"","what":"National Study of Long-Term Care Providers (NSLTCP) Residential Care Community (RCC) Services User (SU) 2018 Public Use File (PUF) — rccsu2018","title":"National Study of Long-Term Care Providers (NSLTCP) Residential Care Community (RCC) Services User (SU) 2018 Public Use File (PUF) — rccsu2018","text":"data system RCC residents.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/rccsu2018.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"National Study of Long-Term Care Providers (NSLTCP) Residential Care Community (RCC) Services User (SU) 2018 Public Use File (PUF) — rccsu2018","text":"","code":"rccsu2018"},{"path":"https://cdcgov.github.io/surveytable/reference/rccsu2018.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"National Study of Long-Term Care Providers (NSLTCP) Residential Care Community (RCC) Services User (SU) 2018 Public Use File (PUF) — rccsu2018","text":"object class survey.design2 (inherits survey.design) 904 rows 81 columns.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/rccsu2018.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"National Study of Long-Term Care Providers (NSLTCP) Residential Care Community (RCC) Services User (SU) 2018 Public Use File (PUF) — rccsu2018","text":"SAS data: https://ftp.cdc.gov/pub/Health_Statistics/NCHS/Datasets/NPALS/final2018rcc_su_puf.sas7bdat Documentation: https://www.cdc.gov/nchs/npals/RCCresident-readme03152021vr.pdf Codebook: https://www.cdc.gov/nchs/data/npals/final2018rcc_su_puf_codebook.pdf","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/set_opts.html","id":null,"dir":"Reference","previous_headings":"","what":"Set certain options — set_opts","title":"Set certain options — set_opts","text":"set_opts() sets certain options. show_opts() shows options set. advanced users can also use options() show_options() detailed control.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/set_opts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set certain options — set_opts","text":"","code":"set_opts(   mode = NULL,   count = NULL,   lpe = NULL,   drop_na = NULL,   max_levels = NULL,   csv = NULL )  show_opts()"},{"path":"https://cdcgov.github.io/surveytable/reference/set_opts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set certain options — set_opts","text":"mode \"general\" \"NCHS\". See details. count round counts nearest: integer (\"int\") one thousand (\"1k\") lpe identify low-precision estimates? drop_na drop missing values (NA)? Categorical variables . max_levels categorical variable can many levels. Used avoid printing huge tables. csv name CSV file \"\" turn CSV output","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/set_opts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set certain options — set_opts","text":"(Nothing.)","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/set_opts.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Set certain options — set_opts","text":"setting particular option, leave NULL. mode can either \"general\" \"NCHS\" following meaning: \"general\": Round counts nearest integer -- count = \"int\". look low-precision estimates -- lpe = FALSE. Percentage CI's: use standard Korn-Graubard CI's. \"nchs\": Round counts nearest 1,000 -- count = \"1k\". Identify low-precision estimates -- lpe = TRUE. Percentage CI's: adjust Korn-Graubard CI's number degrees freedom, matching SUDAAN calculation.","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/set_opts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set certain options — set_opts","text":"","code":"# 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."},{"path":"https://cdcgov.github.io/surveytable/reference/set_survey.html","id":null,"dir":"Reference","previous_headings":"","what":"Specify the survey to analyze — set_survey","title":"Specify the survey to analyze — set_survey","text":"must specify survey functions, tab(), work. convert data.frame survey object, see survey::svydesign() survey::svrepdesign().","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/set_survey.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Specify the survey to analyze — set_survey","text":"","code":"set_survey(design, csv = getOption(\"surveytable.csv\"), ...)"},{"path":"https://cdcgov.github.io/surveytable/reference/set_survey.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Specify the survey to analyze — set_survey","text":"design either survey object (created survey::svydesign() survey::svrepdesign()); , unweighted survey, data.frame. csv name CSV file ... arguments set_opts().","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/set_survey.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Specify the survey to analyze — set_survey","text":"info survey","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/set_survey.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Specify the survey to analyze — set_survey","text":"Optionally, survey can attribute called label, long name survey. Optionally, variable survey can attribute called label, variable's long name.","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/set_survey.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Specify the survey to analyze — set_survey","text":"","code":"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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  set_survey(namcs2019sv, mode = \"general\") #> * Mode: General. #>                         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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>"},{"path":"https://cdcgov.github.io/surveytable/reference/show_options.html","id":null,"dir":"Reference","previous_headings":"","what":"Show package options — show_options","title":"Show package options — show_options","text":"See surveytable-options discussion options.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/show_options.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Show package options — show_options","text":"","code":"show_options(sw = \"surveytable\")"},{"path":"https://cdcgov.github.io/surveytable/reference/show_options.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Show package options — show_options","text":"sw starting characters","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/show_options.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Show package options — show_options","text":"List options values.","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/show_options.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Show package options — show_options","text":"","code":"show_options() #> $surveytable.adjust_svyciprop #> [1] FALSE #>  #> $surveytable.adjust_svyciprop.df_method #> [1] \"NHIS\" #>  #> $surveytable.csv #> [1] \"\" #>  #> $surveytable.drop_na #> [1] FALSE #>  #> $surveytable.find_lpe #> [1] FALSE #>  #> $surveytable.lpe_counts #> [1] \".lpe_counts\" #>  #> $surveytable.lpe_n #> [1] \".lpe_n\" #>  #> $surveytable.lpe_percents #> [1] \".lpe_percents\" #>  #> $surveytable.max_levels #> [1] 20 #>  #> $surveytable.names_count #> [1] \"n\"      \"Number\" \"SE\"     \"LL\"     \"UL\"     #>  #> $surveytable.names_prct #> [1] \"Percent\" \"SE\"      \"LL\"      \"UL\"      #>  #> $surveytable.p.adjust_method #> [1] \"bonferroni\" #>  #> $surveytable.rate_per #> [1] 100 #>  #> $surveytable.survey_label #> [1] \"NAMCS 2019 PUF\" #>  #> $surveytable.svychisq_statistic #> [1] \"F\" #>  #> $surveytable.tx_count #> [1] \".tx_count_int\" #>  #> $surveytable.tx_numeric #> [1] \".tx_numeric\" #>  #> $surveytable.tx_prct #> [1] \".tx_prct\" #>  #> $surveytable.tx_rate #> [1] \".tx_rate\" #>"},{"path":"https://cdcgov.github.io/surveytable/reference/surveytable-options.html","id":null,"dir":"Reference","previous_headings":"","what":"Package options — surveytable-options","title":"Package options — surveytable-options","text":"Run show_options() see available options. description notable options.","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/surveytable-options.html","id":"low-precision-estimates-","dir":"Reference","previous_headings":"","what":"Low-precision estimates.","title":"Package options — surveytable-options","text":"Optionally, tabulation functions can identify low-precision estimates. Turn functionality using following: set_opts(lpe = TRUE), set_opts(mode = \"nchs\"), set_survey(*, mode = \"nchs\"), options(surveytable.find_lpe = TRUE). default, low-precision estimates identified using National Center Health Statistics (NCHS) algorithms. However, can changed, described . description options related identification low-precision estimates. surveytable.find_lpe: tabulation functions look low-precision estimates? can change directly options() either set_opts() set_survey(). surveytable.lpe_n, surveytable.lpe_counts, surveytable.lpe_percents: names 3 functions. argument surveytable.lpe_n vector number observations level variable. argument surveytable.lpe_counts data frame count-related estimates. Specifically, data frame following variables: x: point estimates counts s: SE ll, ul: CI samp.size: effective sample size counts: actual sample size degf: degrees freedom argument surveytable.lpe_percents data frame percent-related estimates. Specifically, data frame following variables: Proportion: point estimates proportions (0 1) SE: SE LL, UL: CI n numerator: number observations variable TRUE n denominator: total number observations functions must return list following elements: id: name algorithm used, \"NCHS presentation standards\" flags: vector. level variable, short codes indicating presence low-precision estimates. .flag: vector short codes present flags. descriptions: named vector. names must short codes, values longer descriptions. example, variable 3 levels, flags might c(\"\", \"A1 A2\", \"\"). indicates first third level, nothing found, whereas second level, two different things found, indicated short codes A1 A2. case, .flag = c(\"A1\", \"A2\"), descriptions = c(A1 = \"A1: something\", A2 = \"A2: something else\").","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/surveytable-options.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Package options — surveytable-options","text":"Maintainer: Alex Strashny AStrashny@cdc.gov (ORCID)","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/surveytable-package.html","id":null,"dir":"Reference","previous_headings":"","what":"surveytable: Formatted Survey Estimates — surveytable-package","title":"surveytable: Formatted Survey Estimates — surveytable-package","text":"Short understandable commands generate tabulated, formatted, rounded survey estimates. Mostly wrapper 'survey' package (Lumley (2004) doi:10.18637/jss.v009.i08  https://CRAN.R-project.org/package=survey) identifies low-precision estimates using National Center Health Statistics (NCHS) presentation standards (Parker et al. (2017) https://www.cdc.gov/nchs/data/series/sr_02/sr02_175.pdf, Parker et al. (2023) doi:10.15620/cdc:124368 ).","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/surveytable-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"surveytable: Formatted Survey Estimates — surveytable-package","text":"Maintainer: Alex Strashny AStrashny@cdc.gov (ORCID)","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/survey_subset.html","id":null,"dir":"Reference","previous_headings":"","what":"Subset a survey, while preserving variable labels — survey_subset","title":"Subset a survey, while preserving variable labels — survey_subset","text":"Subset survey, preserving variable labels","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/survey_subset.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Subset a survey, while preserving variable labels — survey_subset","text":"","code":"survey_subset(design, subset, label)"},{"path":"https://cdcgov.github.io/surveytable/reference/survey_subset.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Subset a survey, while preserving variable labels — survey_subset","text":"design survey object subset expression specifying sub-population label survey label newly created survey object","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/survey_subset.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Subset a survey, while preserving variable labels — survey_subset","text":"new survey object","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/survey_subset.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Subset a survey, while preserving variable labels — survey_subset","text":"","code":"children = survey_subset(namcs2019sv, AGE < 18, \"Children < 18\") set_survey(children) #>                          Survey info {Children < 18}                          #> ┌───────────┬──────────────┬────────────────────────────────────────────────┐ #> │ Variables │ Observations │ Design                                         │ #> ├───────────┼──────────────┼────────────────────────────────────────────────┤ #> │        33 │        1,066 │ Stratified 1 - level Cluster Sampling design   │ #> │           │              │ (with replacement)                             │ #> │           │              │ With (139) clusters.                           │ #> │           │              │ survey_subset(namcs2019sv, AGE < 18, \"Children │ #> │           │              │ < 18\")                                         │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  tab(\"AGER\") #>                                    Patient age recode {Children < 18}                                     #> ┌─────────────┬─────┬─────────────┬────────────┬────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ 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 │    86.1 │ 1.6 │ 82.5 │ 89.2 │ #> │ years       │     │             │            │            │             │         │     │      │      │ #> ├─────────────┼─────┼─────────────┼────────────┼────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 15-24 years │ 179 │  19,003,548 │  2,871,580 │ 14,050,905 │  25,701,891 │    13.9 │ 1.6 │ 10.8 │ 17.5 │ #> └─────────────┴─────┴─────────────┴────────────┴────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 1066.                                                                                               #>"},{"path":"https://cdcgov.github.io/surveytable/reference/svyciprop_adjusted.html","id":null,"dir":"Reference","previous_headings":"","what":"Confidence intervals for proportions, adjusted for degrees of freedom — svyciprop_adjusted","title":"Confidence intervals for proportions, adjusted for degrees of freedom — svyciprop_adjusted","text":"version survey::svyciprop() adjusts degrees freedom method = \"beta\".","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/svyciprop_adjusted.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Confidence intervals for proportions, adjusted for degrees of freedom — svyciprop_adjusted","text":"","code":"svyciprop_adjusted(   formula,   design,   method = c(\"logit\", \"likelihood\", \"asin\", \"beta\", \"mean\", \"xlogit\"),   level = 0.95,   df_method,   ... )"},{"path":"https://cdcgov.github.io/surveytable/reference/svyciprop_adjusted.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Confidence intervals for proportions, adjusted for degrees of freedom — svyciprop_adjusted","text":"formula see survey::svyciprop(). design see survey::svyciprop(). method see survey::svyciprop(). level see survey::svyciprop(). df_method df calculated: \"default\" \"NHIS\". ... see survey::svyciprop().","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/svyciprop_adjusted.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Confidence intervals for proportions, adjusted for degrees of freedom — svyciprop_adjusted","text":"point estimate proportion, confidence interval attribute.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/svyciprop_adjusted.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Confidence intervals for proportions, adjusted for degrees of freedom — svyciprop_adjusted","text":"Written Makram Talih 2019. df_method: \"default\", df = degf(design); \"NHIS\", df = nrow(design) - 1. use function tabulations, call set_survey() set_opts() mode = \"NCHS\" argument, type: options(surveytable.adjust_svyciprop = TRUE).","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/svyciprop_adjusted.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Confidence intervals for proportions, adjusted for degrees of freedom — svyciprop_adjusted","text":"","code":"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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  set_opts(mode = \"NCHS\") #> * Mode: NCHS. tab(\"AGER\") #>                                 Patient age recode {NAMCS 2019 PUF}                                  #> ┌─────────────┬───────┬─────────────┬──────────┬──────────┬──────────┬─────────┬─────┬──────┬──────┐ #> │ Level       │     n │      Number │ SE (000) │ LL (000) │ UL (000) │ Percent │  SE │   LL │   UL │ #> │             │       │       (000) │          │          │          │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼──────────┼──────────┼──────────┼─────────┼─────┼──────┼──────┤ #> │ 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. Checked NCHS presentation standards. Nothing to report.                                  #>  set_opts(mode = \"general\") #> * Mode: General."},{"path":"https://cdcgov.github.io/surveytable/reference/tab.html","id":null,"dir":"Reference","previous_headings":"","what":"Tabulate variables — tab","title":"Tabulate variables — tab","text":"Tabulate categorical (factor), logical, numeric variables.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/tab.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tabulate variables — tab","text":"","code":"tab(   ...,   test = FALSE,   alpha = 0.05,   p_adjust = FALSE,   drop_na = getOption(\"surveytable.drop_na\"),   max_levels = getOption(\"surveytable.max_levels\"),   csv = getOption(\"surveytable.csv\") )"},{"path":"https://cdcgov.github.io/surveytable/reference/tab.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tabulate variables — tab","text":"... names variables (quotes) test perform hypothesis tests? alpha significance level tests p_adjust adjust p-values multiple comparisons? drop_na drop missing values (NA)? Categorical variables . max_levels categorical variable can many levels. Used avoid printing huge tables. csv name CSV file","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/tab.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tabulate variables — tab","text":"list tables single table.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/tab.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tabulate variables — tab","text":"categorical logical variables, presents estimated counts, standard errors (SEs) confidence intervals (CIs), percentages, SEs CIs. Checks presentation guidelines counts percentages flags estimates , according guidelines, suppressed, footnoted, reviewed analyst. numeric variables, presents percentage observations known values, mean known values, standard error mean (SEM), standard deviation (SD). CIs calculated 95% confidence level. CIs count estimates log Student's t CIs, adaptations complex surveys. CIs percentage estimates Korn Graubard CIs.","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/tab.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tabulate variables — tab","text":"","code":"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.                                                                                                  #>  tab(\"MDDO\", \"SPECCAT\", \"MSA\") #>                                  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.                                                                                                  #>   # Numeric variables tab(\"NUMMED\") #> Number of medications coded {NAMCS 2019 PUF} #> ┌─────────┬──────┬───────┬──────┐ #> │ % known │ Mean │   SEM │   SD │ #> ├─────────┼──────┼───────┼──────┤ #> │     100 │ 3.46 │ 0.268 │ 4.43 │ #> └─────────┴──────┴───────┴──────┘ #>   # Hypothesis testing with categorical variables tab(\"AGER\", test = TRUE) #>                                     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.                                                                                                  #>  #> Comparison of all possible pairs of Patient age recode {NAMCS 2019 PUF} #> ┌────────────────┬───────────────────┬─────────┬──────┐ #> │ Level 1        │ Level 2           │ p-value │ Flag │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ Under 15 years │ 15-24 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ Under 15 years │ 25-44 years       │   0.012 │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ Under 15 years │ 45-64 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ Under 15 years │ 65-74 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ Under 15 years │ 75 years and over │   0.022 │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 15-24 years    │ 25-44 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 15-24 years    │ 45-64 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 15-24 years    │ 65-74 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 15-24 years    │ 75 years and over │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 25-44 years    │ 45-64 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 25-44 years    │ 65-74 years       │   0.065 │      │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 25-44 years    │ 75 years and over │   0.878 │      │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 45-64 years    │ 65-74 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 45-64 years    │ 75 years and over │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 65-74 years    │ 75 years and over │   0.019 │ *    │ #> └────────────────┴───────────────────┴─────────┴──────┘ #>   Design-based t-test. *: p <= 0.05                     #>"},{"path":"https://cdcgov.github.io/surveytable/reference/tab_rate.html","id":null,"dir":"Reference","previous_headings":"","what":"Calculate rates — tab_rate","title":"Calculate rates — tab_rate","text":"Calculate rates categorical (factor) logical variables.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/tab_rate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Calculate rates — tab_rate","text":"","code":"tab_rate(   vr,   pop,   per = getOption(\"surveytable.rate_per\"),   drop_na = getOption(\"surveytable.drop_na\"),   max_levels = getOption(\"surveytable.max_levels\"),   csv = getOption(\"surveytable.csv\") )"},{"path":"https://cdcgov.github.io/surveytable/reference/tab_rate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Calculate rates — tab_rate","text":"vr variable tabulate pop either single number data.frame columns named Level Population. Level must exactly match levels vr. Population population level vr. per calculate rate per many items population drop_na drop missing values (NA)? max_levels categorical variable can many levels. Used avoid printing huge tables. csv name CSV file","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/tab_rate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Calculate rates — tab_rate","text":"list tables single table.","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/tab_rate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Calculate rates — tab_rate","text":"","code":"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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  # pop is a data frame tab_rate(\"MSA\", uspop2019$MSA) #> Metropolitan Statistical Area Status of physician location (rate per 100 population) {NAMCS 2019 PUF} #> ┌───────────────────────┬───────┬───────┬──────┬───────┬───────┐ #> │ Level                 │     n │  Rate │   SE │    LL │    UL │ #> ├───────────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ MSA (Metropolitan     │ 7,496 │ 351.2 │ 18.2 │ 317.2 │ 388.8 │ #> │ Statistical Area)     │       │       │      │       │       │ #> ├───────────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ Non-MSA               │   754 │ 136.7 │ 38.2 │  78.9 │ 236.8 │ #> └───────────────────────┴───────┴───────┴──────┴───────┴───────┘ #>   N = 8250.                                                      #>   # pop is a single number tab_rate(\"MDDO\", uspop2019$total) #> * Rate based on the entire population. #> Type of doctor (MD or DO) (rate per 100 population) {NAMCS 2019 PUF} #> ┌───────────────────────┬───────┬───────┬────┬───────┬───────┐ #> │ Level                 │     n │  Rate │ SE │    LL │    UL │ #> ├───────────────────────┼───────┼───────┼────┼───────┼───────┤ #> │ M.D. - Doctor of      │ 7,498 │ 303.3 │ 15 │ 275.3 │ 334.1 │ #> │ Medicine              │       │       │    │       │       │ #> ├───────────────────────┼───────┼───────┼────┼───────┼───────┤ #> │ D.O. - Doctor of      │   752 │  17.4 │  2 │  13.8 │  21.9 │ #> │ Osteopathy            │       │       │    │       │       │ #> └───────────────────────┴───────┴───────┴────┴───────┴───────┘ #>   N = 8250.                                                    #>"},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset.html","id":null,"dir":"Reference","previous_headings":"","what":"Tabulate subsets or interactions — tab_cross","title":"Tabulate subsets or interactions — tab_cross","text":"Create subsets survey using one variable, tabulate another variable within subsets. Interact two variables tabulate.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tabulate subsets or interactions — tab_cross","text":"","code":"tab_cross(   vr,   vrby,   max_levels = getOption(\"surveytable.max_levels\"),   csv = getOption(\"surveytable.csv\") )  tab_subset(   vr,   vrby,   lvls = c(),   test = FALSE,   alpha = 0.05,   p_adjust = FALSE,   drop_na = getOption(\"surveytable.drop_na\"),   max_levels = getOption(\"surveytable.max_levels\"),   csv = getOption(\"surveytable.csv\") )"},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tabulate subsets or interactions — tab_cross","text":"vr variable tabulate vrby use variable subset survey max_levels categorical variable can many levels. Used avoid printing huge tables. csv name CSV file lvls (optional) show levels vrby test perform hypothesis tests? alpha significance level tests p_adjust adjust p-values multiple comparisons? drop_na drop missing values (NA)? Categorical variables .","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tabulate subsets or interactions — tab_cross","text":"list tables single table.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tabulate subsets or interactions — tab_cross","text":"tab_subset creates subsets using levels vrby, tabulates vr subset. Optionally, use lvls levels vrby. vr can categorical (factor), logical, numeric. tab_cross crosses interacts vr vrby tabulates new variable. Tables created using tab_subset tab_cross counts different percentages. tab_subset, percentages within subset add 100%. tab_cross, percentages across entire population add 100%. Also see var_cross(). test = TRUE performs test association two variables. Also performs t-tests possible pairs levels vr vrby.","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tabulate subsets or interactions — tab_cross","text":"","code":"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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>   # For each SEX, tabulate AGER tab_subset(\"AGER\", \"SEX\") #>                          Patient age recode (Patient sex = Female) {NAMCS 2019 PUF}                          #> ┌─────────────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level       │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Under 15    │   434 │  59,957,823 │  7,205,594 │  47,318,228 │  75,973,693 │     9.9 │ 1.2 │  7.6 │ 12.6 │ #> │ years       │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 15-24 years │   346 │  41,128,003 │  4,532,466 │  33,065,609 │  51,156,253 │     6.8 │ 0.7 │  5.4 │  8.4 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 25-44 years │   923 │ 113,708,461 │ 11,461,189 │  93,256,445 │ 138,645,797 │    18.8 │ 1.6 │ 15.8 │ 22.1 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 45-64 years │ 1,253 │ 175,978,133 │ 16,008,541 │ 147,152,826 │ 210,449,940 │    29.1 │ 1.7 │ 25.7 │ 32.6 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 65-74 years │   891 │ 120,099,493 │ 11,066,146 │ 100,171,315 │ 143,992,203 │    19.8 │ 1.5 │ 17   │ 22.9 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 75 years    │   762 │  94,173,155 │ 11,085,372 │  74,682,310 │ 118,750,789 │    15.6 │ 1.5 │ 12.8 │ 18.7 │ #> │ and over    │       │             │            │             │             │         │     │      │      │ #> └─────────────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 4609.                                                                                                  #>  #>                           Patient age recode (Patient sex = Male) {NAMCS 2019 PUF}                           #> ┌─────────────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level       │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Under 15    │   453 │  57,958,950 │  7,727,594 │  44,569,688 │  75,370,504 │    13.4 │ 1.7 │ 10.3 │ 17.1 │ #> │ years       │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 15-24 years │   196 │  23,727,695 │  4,343,932 │  16,457,071 │  34,210,431 │     5.5 │ 0.8 │  4   │  7.4 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 25-44 years │   512 │  56,562,143 │  7,276,983 │  43,860,836 │  72,941,520 │    13.1 │ 1.3 │ 10.7 │ 15.8 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 45-64 years │ 1,030 │ 133,527,822 │ 12,956,239 │ 110,319,199 │ 161,619,006 │    30.9 │ 1.6 │ 27.8 │ 34.3 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 65-74 years │   770 │  86,766,489 │  6,766,876 │  74,409,284 │ 101,175,865 │    20.1 │ 1.5 │ 17.3 │ 23.1 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 75 years    │   680 │  72,896,189 │  6,660,855 │  60,871,965 │  87,295,593 │    16.9 │ 1.5 │ 14   │ 20.2 │ #> │ and over    │       │             │            │             │             │         │     │      │      │ #> └─────────────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 3641.                                                                                                  #>   # Same counts as tab_subset(), but different percentages. tab_cross(\"AGER\", \"SEX\") #>                            (Patient age recode) x (Patient sex) {NAMCS 2019 PUF}                             #> ┌─────────────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level       │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Under 15    │   434 │  59,957,823 │  7,205,594 │  47,318,228 │  75,973,693 │     5.8 │ 0.7 │  4.5 │  7.3 │ #> │ years:      │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 15-24       │   346 │  41,128,003 │  4,532,466 │  33,065,609 │  51,156,253 │     4   │ 0.4 │  3.2 │  4.9 │ #> │ years:      │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 25-44       │   923 │ 113,708,461 │ 11,461,189 │  93,256,445 │ 138,645,797 │    11   │ 1   │  9   │ 13.2 │ #> │ years:      │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 45-64       │ 1,253 │ 175,978,133 │ 16,008,541 │ 147,152,826 │ 210,449,940 │    17   │ 1.1 │ 14.8 │ 19.3 │ #> │ years:      │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 65-74       │   891 │ 120,099,493 │ 11,066,146 │ 100,171,315 │ 143,992,203 │    11.6 │ 1   │  9.7 │ 13.7 │ #> │ years:      │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 75 years    │   762 │  94,173,155 │ 11,085,372 │  74,682,310 │ 118,750,789 │     9.1 │ 0.9 │  7.3 │ 11.1 │ #> │ and over:   │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Under 15    │   453 │  57,958,950 │  7,727,594 │  44,569,688 │  75,370,504 │     5.6 │ 0.7 │  4.3 │  7.2 │ #> │ years: Male │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 15-24       │   196 │  23,727,695 │  4,343,932 │  16,457,071 │  34,210,431 │     2.3 │ 0.4 │  1.6 │  3.2 │ #> │ years: Male │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 25-44       │   512 │  56,562,143 │  7,276,983 │  43,860,836 │  72,941,520 │     5.5 │ 0.6 │  4.3 │  6.8 │ #> │ years: Male │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 45-64       │ 1,030 │ 133,527,822 │ 12,956,239 │ 110,319,199 │ 161,619,006 │    12.9 │ 1   │ 10.9 │ 15.1 │ #> │ years: Male │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 65-74       │   770 │  86,766,489 │  6,766,876 │  74,409,284 │ 101,175,865 │     8.4 │ 0.6 │  7.2 │  9.7 │ #> │ years: Male │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 75 years    │   680 │  72,896,189 │  6,660,855 │  60,871,965 │  87,295,593 │     7   │ 0.6 │  5.9 │  8.3 │ #> │ and over:   │       │             │            │             │             │         │     │      │      │ #> │ Male        │       │             │            │             │             │         │     │      │      │ #> └─────────────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                                  #>   # Numeric variables tab_subset(\"NUMMED\", \"AGER\") #> Number of medications coded (for different levels of Patient age recode) {NAMCS 2019 PUF} #> ┌───────────────────┬─────────┬──────┬───────┬──────┐ #> │ Level             │ % known │ Mean │   SEM │   SD │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ Under 15 years    │     100 │ 1.58 │ 0.168 │ 1.75 │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ 15-24 years       │     100 │ 1.64 │ 0.112 │ 1.7  │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ 25-44 years       │     100 │ 2.15 │ 0.225 │ 2.74 │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ 45-64 years       │     100 │ 3.49 │ 0.303 │ 4.49 │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ 65-74 years       │     100 │ 4.44 │ 0.431 │ 5.03 │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ 75 years and over │     100 │ 5.53 │ 0.494 │ 5.59 │ #> └───────────────────┴─────────┴──────┴───────┴──────┘ #>   # Hypothesis testing tab_subset(\"NUMMED\", \"AGER\", test = TRUE) #> Number of medications coded (for different levels of Patient age recode) {NAMCS 2019 PUF} #> ┌───────────────────┬─────────┬──────┬───────┬──────┐ #> │ Level             │ % known │ Mean │   SEM │   SD │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ Under 15 years    │     100 │ 1.58 │ 0.168 │ 1.75 │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ 15-24 years       │     100 │ 1.64 │ 0.112 │ 1.7  │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ 25-44 years       │     100 │ 2.15 │ 0.225 │ 2.74 │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ 45-64 years       │     100 │ 3.49 │ 0.303 │ 4.49 │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ 65-74 years       │     100 │ 4.44 │ 0.431 │ 5.03 │ #> ├───────────────────┼─────────┼──────┼───────┼──────┤ #> │ 75 years and over │     100 │ 5.53 │ 0.494 │ 5.59 │ #> └───────────────────┴─────────┴──────┴───────┴──────┘ #>  #> Association between Number of medications coded and Patient age recode {NAMCS 2019 PUF} #> ┌──────────────┬──────────────┐ #> │      p-value │ Flag         │ #> ├──────────────┼──────────────┤ #> │            0 │ *            │ #> └──────────────┴──────────────┘ #>   Wald test. *: p <= 0.05       #>  #> Comparison of Number of medications coded across all possible pairs of Patient age recode {NAMCS 2019 PUF} #> ┌────────────────┬───────────────────┬─────────┬──────┐ #> │ Level 1        │ Level 2           │ p-value │ Flag │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ Under 15 years │ 15-24 years       │   0.739 │      │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ Under 15 years │ 25-44 years       │   0.043 │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ Under 15 years │ 45-64 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ Under 15 years │ 65-74 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ Under 15 years │ 75 years and over │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 15-24 years    │ 25-44 years       │   0.029 │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 15-24 years    │ 45-64 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 15-24 years    │ 65-74 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 15-24 years    │ 75 years and over │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 25-44 years    │ 45-64 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 25-44 years    │ 65-74 years       │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 25-44 years    │ 75 years and over │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 45-64 years    │ 65-74 years       │   0.007 │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 45-64 years    │ 75 years and over │   0     │ *    │ #> ├────────────────┼───────────────────┼─────────┼──────┤ #> │ 65-74 years    │ 75 years and over │   0.002 │ *    │ #> └────────────────┴───────────────────┴─────────┴──────┘ #>   Design-based t-test. *: p <= 0.05                     #>"},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset_rate.html","id":null,"dir":"Reference","previous_headings":"","what":"Calculate rates for subsets — tab_subset_rate","title":"Calculate rates for subsets — tab_subset_rate","text":"Create subsets survey using one variable, tabulate rates another variable within subsets.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset_rate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Calculate rates for subsets — tab_subset_rate","text":"","code":"tab_subset_rate(   vr,   vrby,   pop,   lvls = c(),   per = getOption(\"surveytable.rate_per\"),   drop_na = getOption(\"surveytable.drop_na\"),   max_levels = getOption(\"surveytable.max_levels\"),   csv = getOption(\"surveytable.csv\") )"},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset_rate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Calculate rates for subsets — tab_subset_rate","text":"vr variable tabulate vrby use variable subset survey pop data.frame columns named Level, Subset, Population. Level must exactly match levels vr. Subset must exactly match levels vrby. Population population level vr vrby. lvls (optional) show levels vrby per calculate rate per many items population drop_na drop missing values (NA)? max_levels categorical variable can many levels. Used avoid printing huge tables. csv name CSV file","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset_rate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Calculate rates for subsets — tab_subset_rate","text":"list tables single table.","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/tab_subset_rate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Calculate rates for subsets — tab_subset_rate","text":"","code":"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_subset_rate(\"AGER\", \"SEX\", uspop2019$`AGER x SEX`) #> Patient age recode (Patient sex = Female) (rate per 100 population) {NAMCS 2019 PUF} #> ┌───────────────────┬───────┬───────┬──────┬───────┬───────┐ #> │ Level             │     n │  Rate │   SE │    LL │    UL │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ Under 15 years    │   434 │ 202.5 │ 24.3 │ 159.8 │ 256.6 │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ 15-24 years       │   346 │ 198.4 │ 21.9 │ 159.5 │ 246.8 │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ 25-44 years       │   923 │ 263.3 │ 26.5 │ 215.9 │ 321   │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ 45-64 years       │ 1,253 │ 414   │ 37.7 │ 346.2 │ 495.1 │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ 65-74 years       │   891 │ 720.3 │ 66.4 │ 600.8 │ 863.6 │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ 75 years and over │   762 │ 758.1 │ 89.2 │ 601.2 │ 956   │ #> └───────────────────┴───────┴───────┴──────┴───────┴───────┘ #>   N = 4609.                                                  #>  #> Patient age recode (Patient sex = Male) (rate per 100 population) {NAMCS 2019 PUF} #> ┌───────────────────┬───────┬───────┬──────┬───────┬───────┐ #> │ Level             │     n │  Rate │   SE │    LL │    UL │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ Under 15 years    │   453 │ 187.4 │ 25   │ 144.1 │ 243.7 │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ 15-24 years       │   196 │ 113.1 │ 20.7 │  78.4 │ 163   │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ 25-44 years       │   512 │ 133.4 │ 17.2 │ 103.4 │ 172   │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ 45-64 years       │ 1,030 │ 333.4 │ 32.3 │ 275.4 │ 403.5 │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ 65-74 years       │   770 │ 594.8 │ 46.4 │ 510.1 │ 693.6 │ #> ├───────────────────┼───────┼───────┼──────┼───────┼───────┤ #> │ 75 years and over │   680 │ 801.2 │ 73.2 │ 669.1 │ 959.5 │ #> └───────────────────┴───────┴───────┴──────┴───────┴───────┘ #>   N = 3641.                                                  #>"},{"path":"https://cdcgov.github.io/surveytable/reference/total.html","id":null,"dir":"Reference","previous_headings":"","what":"Total count — total","title":"Total count — total","text":"Total count","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/total.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Total count — total","text":"","code":"total(csv = getOption(\"surveytable.csv\"))"},{"path":"https://cdcgov.github.io/surveytable/reference/total.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Total count — total","text":"csv name CSV file","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/total.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Total count — total","text":"table","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/total.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Total count — total","text":"","code":"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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  total() #>                        Total {NAMCS 2019 PUF}                        #> ┌───────┬───────────────┬────────────┬─────────────┬───────────────┐ #> │     n │        Number │         SE │          LL │            UL │ #> ├───────┼───────────────┼────────────┼─────────────┼───────────────┤ #> │ 8,250 │ 1,036,484,356 │ 48,836,217 │ 945,013,590 │ 1,136,808,860 │ #> └───────┴───────────────┴────────────┴─────────────┴───────────────┘ #>   N = 8250.                                                          #>"},{"path":"https://cdcgov.github.io/surveytable/reference/total_rate.html","id":null,"dir":"Reference","previous_headings":"","what":"Overall rate — total_rate","title":"Overall rate — total_rate","text":"Overall rate","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/total_rate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Overall rate — total_rate","text":"","code":"total_rate(   pop,   per = getOption(\"surveytable.rate_per\"),   csv = getOption(\"surveytable.csv\") )"},{"path":"https://cdcgov.github.io/surveytable/reference/total_rate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Overall rate — total_rate","text":"pop population per calculate rate per many items population csv name CSV file","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/total_rate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Overall rate — total_rate","text":"table","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/total_rate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Overall rate — total_rate","text":"","code":"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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  total_rate(uspop2019$total) #> Total (rate per 100 population) {NAMCS 2019 PUF} #> ┌───────┬───────┬──────┬───────┬───────┐ #> │     n │  Rate │   SE │    LL │    UL │ #> ├───────┼───────┼──────┼───────┼───────┤ #> │ 8,250 │ 320.7 │ 15.1 │ 292.4 │ 351.7 │ #> └───────┴───────┴──────┴───────┴───────┘ #>   N = 8250.                              #>"},{"path":"https://cdcgov.github.io/surveytable/reference/uspop2019.html","id":null,"dir":"Reference","previous_headings":"","what":"US Population in 2019 — uspop2019","title":"US Population in 2019 — uspop2019","text":"Population estimates civilian non-institutional population United States July 1, 2019. Used calculating rates. usage examples, see *_rate functions.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/uspop2019.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"US Population in 2019 — uspop2019","text":"","code":"uspop2019"},{"path":"https://cdcgov.github.io/surveytable/reference/uspop2019.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"US Population in 2019 — uspop2019","text":"object class list length 7.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_all.html","id":null,"dir":"Reference","previous_headings":"","what":"Are all the variables true? (Logical AND) — var_all","title":"Are all the variables true? (Logical AND) — var_all","text":"Create new variable true variables list variables true.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_all.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Are all the variables true? (Logical AND) — var_all","text":"","code":"var_all(newvr, vrs)"},{"path":"https://cdcgov.github.io/surveytable/reference/var_all.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Are all the variables true? (Logical AND) — var_all","text":"newvr name new variable created vrs vector logical variables","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_all.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Are all the variables true? (Logical AND) — var_all","text":"Survey object","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/var_all.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Are all the variables true? (Logical AND) — var_all","text":"","code":"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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  var_all(\"Medicare and Medicaid\", c(\"PAYMCARE\", \"PAYMCAID\")) tab(\"Medicare and Medicaid\") #>                                 Medicare and Medicaid {NAMCS 2019 PUF}                                 #> ┌───────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ FALSE │ 8,126 │ 1,016,202,0 │ 47,395,074 │ 927,388,977 │ 1,113,520,4 │      98 │ 0.5 │ 96.9 │ 98.9 │ #> │       │       │          62 │            │             │          92 │         │     │      │      │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ TRUE  │   124 │  20,282,295 │  5,177,254 │  12,120,309 │  33,940,676 │       2 │ 0.5 │  1.1 │  3.1 │ #> └───────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                            #>"},{"path":"https://cdcgov.github.io/surveytable/reference/var_any.html","id":null,"dir":"Reference","previous_headings":"","what":"Is any variable true? (Logical OR) — var_any","title":"Is any variable true? (Logical OR) — var_any","text":"Create new variable true variables list variables true.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_any.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is any variable true? (Logical OR) — var_any","text":"","code":"var_any(newvr, vrs)"},{"path":"https://cdcgov.github.io/surveytable/reference/var_any.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is any variable true? (Logical OR) — var_any","text":"newvr name new variable created vrs vector logical variables","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_any.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is any variable true? (Logical OR) — var_any","text":"Survey object","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/var_any.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is any variable true? (Logical OR) — var_any","text":"","code":"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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  var_any(\"Imaging services\" , c(\"ANYIMAGE\", \"BONEDENS\", \"CATSCAN\", \"ECHOCARD\", \"OTHULTRA\" , \"MAMMO\", \"MRI\", \"XRAY\", \"OTHIMAGE\")) tab(\"Imaging services\") #>                                   Imaging services {NAMCS 2019 PUF}                                    #> ┌───────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ FALSE │ 7,148 │ 901,115,076 │ 43,298,146 │ 820,085,161 │ 990,151,291 │    86.9 │ 1.1 │ 84.6 │ 89.1 │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ TRUE  │ 1,102 │ 135,369,280 │ 13,573,736 │ 111,133,847 │ 164,889,838 │    13.1 │ 1.1 │ 10.9 │ 15.4 │ #> └───────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                            #>"},{"path":"https://cdcgov.github.io/surveytable/reference/var_case.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert factor to logical — var_case","title":"Convert factor to logical — var_case","text":"Convert factor logical","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_case.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert factor to logical — var_case","text":"","code":"var_case(newvr, vr, cases, retain_na = TRUE)"},{"path":"https://cdcgov.github.io/surveytable/reference/var_case.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert factor to logical — var_case","text":"newvr name new logical variable created vr factor variable cases one levels vr converted TRUE. levels converted FALSE. retain_na observations vr NA, newvr NA well?","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_case.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert factor to logical — var_case","text":"Survey object","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/var_case.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert factor to logical — var_case","text":"","code":"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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>   var_case(\"Preventive care visits\", \"MAJOR\", \"Preventive care\") tab(\"Preventive care visits\") #>                                Preventive care visits {NAMCS 2019 PUF}                                 #> ┌───────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ FALSE │ 6,682 │ 812,860,686 │ 45,220,483 │ 728,841,389 │ 906,565,549 │    78.4 │ 1.7 │ 74.9 │ 81.7 │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ TRUE  │ 1,568 │ 223,623,671 │ 18,519,789 │ 190,068,005 │ 263,103,441 │    21.6 │ 1.7 │ 18.3 │ 25.1 │ #> └───────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                            #>   var_case(\"Surgery-related visits\" , \"MAJOR\" , c(\"Pre-surgery\", \"Post-surgery\")) tab(\"Surgery-related visits\") #>                                Surgery-related visits {NAMCS 2019 PUF}                                 #> ┌───────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ FALSE │ 7,432 │ 969,450,753 │ 47,976,379 │ 879,792,684 │ 1,068,245,7 │    93.5 │ 0.8 │ 91.9 │ 94.9 │ #> │       │       │             │            │             │          12 │         │     │      │      │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ TRUE  │   818 │  67,033,604 │  7,810,237 │  53,273,079 │  84,348,494 │     6.5 │ 0.8 │  5.1 │  8.1 │ #> └───────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                            #>   var_case(\"Non-primary\" , \"SPECCAT.bad\" , c(\"Surgical care specialty\", \"Medical care specialty\")) tab(\"Non-primary\") #>                                      Non-primary {NAMCS 2019 PUF}                                      #> ┌───────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ FALSE │ 2,406 │ 422,806,843 │ 26,381,877 │ 374,098,520 │ 477,857,080 │    40.8 │ 2.2 │ 36.5 │ 45.2 │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ TRUE  │ 4,194 │ 406,215,659 │ 32,642,950 │ 346,937,333 │ 475,622,385 │    39.2 │ 2.1 │ 35   │ 43.5 │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │  │ 1,650 │ 207,461,854 │ 12,457,774 │ 184,377,795 │ 233,436,032 │    20   │ 0.8 │ 18.5 │ 21.6 │ #> └───────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                            #>  tab(\"Non-primary\", drop_na = TRUE) #>                               Non-primary (knowns only) {NAMCS 2019 PUF}                               #> ┌───────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ FALSE │ 2,406 │ 422,806,843 │ 26,381,877 │ 374,098,520 │ 477,857,080 │      51 │ 2.6 │ 45.7 │ 56.3 │ #> ├───────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ TRUE  │ 4,194 │ 406,215,659 │ 32,642,950 │ 346,937,333 │ 475,622,385 │      49 │ 2.6 │ 43.7 │ 54.3 │ #> └───────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 6600.                                                                                            #>"},{"path":"https://cdcgov.github.io/surveytable/reference/var_collapse.html","id":null,"dir":"Reference","previous_headings":"","what":"Collapse factor levels — var_collapse","title":"Collapse factor levels — var_collapse","text":"Collapse two levels factor variable single level.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_collapse.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Collapse factor levels — var_collapse","text":"","code":"var_collapse(vr, newlevel, oldlevels)"},{"path":"https://cdcgov.github.io/surveytable/reference/var_collapse.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Collapse factor levels — var_collapse","text":"vr factor variable newlevel name new level oldlevels vector old levels","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_collapse.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Collapse factor levels — var_collapse","text":"Survey object","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/var_collapse.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Collapse factor levels — var_collapse","text":"","code":"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(\"PRIMCARE\") #>                      Are you the patient's primary care provider? {NAMCS 2019 PUF}                       #> ┌─────────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level   │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├─────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Blank   │    16 │   1,150,066 │    478,377 │     440,081 │   3,005,475 │     0.1 │ 0   │  0   │  0.2 │ #> ├─────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Unknown │   300 │  39,518,576 │  9,507,422 │  24,519,903 │  63,691,845 │     3.8 │ 0.9 │  2.3 │  6   │ #> ├─────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Yes     │ 2,278 │ 383,480,893 │ 28,554,963 │ 331,361,656 │ 443,797,864 │    37   │ 2.6 │ 31.9 │ 42.3 │ #> ├─────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ No      │ 5,656 │ 612,334,822 │ 43,282,478 │ 533,049,777 │ 703,412,608 │    59.1 │ 2.5 │ 53.9 │ 64.1 │ #> └─────────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                              #>  var_collapse(\"PRIMCARE\", \"Unknown if PCP\", c(\"Blank\", \"Unknown\")) tab(\"PRIMCARE\") #>                        Are you the patient's primary care provider? {NAMCS 2019 PUF}                         #> ┌─────────────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level       │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Unknown if  │   316 │  40,668,642 │  9,478,963 │  25,618,707 │  64,559,793 │     3.9 │ 0.9 │  2.4 │  6.1 │ #> │ PCP         │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Yes         │ 2,278 │ 383,480,893 │ 28,554,963 │ 331,361,656 │ 443,797,864 │    37   │ 2.6 │ 31.9 │ 42.3 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ No          │ 5,656 │ 612,334,822 │ 43,282,478 │ 533,049,777 │ 703,412,608 │    59.1 │ 2.5 │ 53.9 │ 64.1 │ #> └─────────────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                                  #>"},{"path":"https://cdcgov.github.io/surveytable/reference/var_copy.html","id":null,"dir":"Reference","previous_headings":"","what":"Copy a variable — var_copy","title":"Copy a variable — var_copy","text":"Create new variable copy another variable. can modify copy, original remains unchanged. See examples.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_copy.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Copy a variable — var_copy","text":"","code":"var_copy(newvr, vr)"},{"path":"https://cdcgov.github.io/surveytable/reference/var_copy.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Copy a variable — var_copy","text":"newvr name new variable created vr variable","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_copy.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Copy a variable — var_copy","text":"Survey object","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/var_copy.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Copy a variable — var_copy","text":"","code":"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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  var_copy(\"Age group\", \"AGER\") var_collapse(\"Age group\", \"65+\", c(\"65-74 years\", \"75 years and over\")) var_collapse(\"Age group\", \"25-64\", c(\"25-44 years\", \"45-64 years\")) tab(\"AGER\", \"Age group\") #>                                     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.                                                                                                  #>  #>                                          Age group {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-64       │ 3,718 │ 479,776,560 │ 32,174,693 │ 420,624,423 │ 547,247,222 │    46.3 │ 1.8 │ 42.7 │ 49.9 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 65+         │ 3,103 │ 373,935,326 │ 24,522,516 │ 328,776,878 │ 425,296,417 │    36.1 │ 1.9 │ 32.3 │ 40   │ #> └─────────────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                                  #>"},{"path":"https://cdcgov.github.io/surveytable/reference/var_cross.html","id":null,"dir":"Reference","previous_headings":"","what":"Cross or interact two variables — var_cross","title":"Cross or interact two variables — var_cross","text":"Create new variable interaction two variables. Also see tab_cross().","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_cross.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cross or interact two variables — var_cross","text":"","code":"var_cross(newvr, vr, vrby)"},{"path":"https://cdcgov.github.io/surveytable/reference/var_cross.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cross or interact two variables — var_cross","text":"newvr name new variable created vr first variable vrby second variable","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_cross.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cross or interact two variables — var_cross","text":"Survey object","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/var_cross.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cross or interact two variables — var_cross","text":"","code":"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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  var_cross(\"Age x Sex\", \"AGER\", \"SEX\") tab(\"Age x Sex\") #>                                          Age x Sex {NAMCS 2019 PUF}                                          #> ┌─────────────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level       │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Under 15    │   434 │  59,957,823 │  7,205,594 │  47,318,228 │  75,973,693 │     5.8 │ 0.7 │  4.5 │  7.3 │ #> │ years:      │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 15-24       │   346 │  41,128,003 │  4,532,466 │  33,065,609 │  51,156,253 │     4   │ 0.4 │  3.2 │  4.9 │ #> │ years:      │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 25-44       │   923 │ 113,708,461 │ 11,461,189 │  93,256,445 │ 138,645,797 │    11   │ 1   │  9   │ 13.2 │ #> │ years:      │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 45-64       │ 1,253 │ 175,978,133 │ 16,008,541 │ 147,152,826 │ 210,449,940 │    17   │ 1.1 │ 14.8 │ 19.3 │ #> │ years:      │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 65-74       │   891 │ 120,099,493 │ 11,066,146 │ 100,171,315 │ 143,992,203 │    11.6 │ 1   │  9.7 │ 13.7 │ #> │ years:      │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 75 years    │   762 │  94,173,155 │ 11,085,372 │  74,682,310 │ 118,750,789 │     9.1 │ 0.9 │  7.3 │ 11.1 │ #> │ and over:   │       │             │            │             │             │         │     │      │      │ #> │ Female      │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Under 15    │   453 │  57,958,950 │  7,727,594 │  44,569,688 │  75,370,504 │     5.6 │ 0.7 │  4.3 │  7.2 │ #> │ years: Male │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 15-24       │   196 │  23,727,695 │  4,343,932 │  16,457,071 │  34,210,431 │     2.3 │ 0.4 │  1.6 │  3.2 │ #> │ years: Male │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 25-44       │   512 │  56,562,143 │  7,276,983 │  43,860,836 │  72,941,520 │     5.5 │ 0.6 │  4.3 │  6.8 │ #> │ years: Male │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 45-64       │ 1,030 │ 133,527,822 │ 12,956,239 │ 110,319,199 │ 161,619,006 │    12.9 │ 1   │ 10.9 │ 15.1 │ #> │ years: Male │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 65-74       │   770 │  86,766,489 │  6,766,876 │  74,409,284 │ 101,175,865 │     8.4 │ 0.6 │  7.2 │  9.7 │ #> │ years: Male │       │             │            │             │             │         │     │      │      │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 75 years    │   680 │  72,896,189 │  6,660,855 │  60,871,965 │  87,295,593 │     7   │ 0.6 │  5.9 │  8.3 │ #> │ and over:   │       │             │            │             │             │         │     │      │      │ #> │ Male        │       │             │            │             │             │         │     │      │      │ #> └─────────────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                                  #>"},{"path":"https://cdcgov.github.io/surveytable/reference/var_cut.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert numeric to factor — var_cut","title":"Convert numeric to factor — var_cut","text":"Create new categorical variable based numeric variable.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_cut.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert numeric to factor — var_cut","text":"","code":"var_cut(newvr, vr, breaks, labels)"},{"path":"https://cdcgov.github.io/surveytable/reference/var_cut.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert numeric to factor — var_cut","text":"newvr name new factor variable created vr numeric variable breaks see cut() labels see cut()","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_cut.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert numeric to factor — var_cut","text":"Survey object","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/var_cut.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert numeric to factor — var_cut","text":"","code":"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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  # In some data systems, variables might contain \"special values\". For example, # negative values might indicate unknowns (which should be coded as `NA`). # Though in this particular data, there are no unknowns. var_cut(\"Age group\"   , \"AGE\"   , c(-Inf, -0.1, 0, 4, 14, 64, Inf)   , c(NA, \"Under 1\", \"1-4\", \"5-14\", \"15-64\", \"65 and over\")) tab(\"Age group\") #>                                          Age group {NAMCS 2019 PUF}                                          #> ┌─────────────┬───────┬─────────────┬────────────┬─────────────┬─────────────┬─────────┬─────┬──────┬──────┐ #> │ Level       │     n │      Number │         SE │          LL │          UL │ Percent │  SE │   LL │   UL │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ Under 1     │   203 │  31,147,553 │  5,281,607 │  22,269,146 │  43,565,662 │     3   │ 0.5 │  2.1 │  4.1 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 1-4         │   281 │  38,240,087 │  5,443,933 │  28,863,791 │  50,662,237 │     3.7 │ 0.5 │  2.7 │  4.8 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 5-14        │   403 │  48,529,132 │  5,741,214 │  38,429,869 │  61,282,455 │     4.7 │ 0.5 │  3.7 │  5.9 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 15-64       │ 4,260 │ 544,632,258 │ 36,082,093 │ 478,254,001 │ 620,223,345 │    52.5 │ 2   │ 48.6 │ 56.5 │ #> ├─────────────┼───────┼─────────────┼────────────┼─────────────┼─────────────┼─────────┼─────┼──────┼──────┤ #> │ 65 and over │ 3,103 │ 373,935,326 │ 24,522,516 │ 328,776,878 │ 425,296,417 │    36.1 │ 1.9 │ 32.3 │ 40   │ #> └─────────────┴───────┴─────────────┴────────────┴─────────────┴─────────────┴─────────┴─────┴──────┴──────┘ #>   N = 8250.                                                                                                  #>"},{"path":"https://cdcgov.github.io/surveytable/reference/var_list.html","id":null,"dir":"Reference","previous_headings":"","what":"List variables in a survey. — var_list","title":"List variables in a survey. — var_list","text":"List variables survey.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_list.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"List variables in a survey. — var_list","text":"","code":"var_list(sw = \"\", all = FALSE, csv = getOption(\"surveytable.csv\"))"},{"path":"https://cdcgov.github.io/surveytable/reference/var_list.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"List variables in a survey. — var_list","text":"sw starting characters variable name (case insensitive) print variables? csv name CSV file","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_list.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"List variables in a survey. — var_list","text":"table","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_list.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"List variables in a survey. — var_list","text":"","code":"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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  var_list(\"age\") #>          Variables beginning with 'age' {NAMCS 2019 PUF}          #> ┌──────────┬─────────┬──────────────────────────────────────────┐ #> │ Variable │ Class   │ Long name                                │ #> ├──────────┼─────────┼──────────────────────────────────────────┤ #> │ AGE      │ numeric │ Patient age in years (raw - use caution) │ #> ├──────────┼─────────┼──────────────────────────────────────────┤ #> │ AGER     │ factor  │ Patient age recode                       │ #> └──────────┴─────────┴──────────────────────────────────────────┘ #>"},{"path":"https://cdcgov.github.io/surveytable/reference/var_not.html","id":null,"dir":"Reference","previous_headings":"","what":"Logical NOT — var_not","title":"Logical NOT — var_not","text":"Logical ","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_not.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Logical NOT — var_not","text":"","code":"var_not(newvr, vr)"},{"path":"https://cdcgov.github.io/surveytable/reference/var_not.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Logical NOT — var_not","text":"newvr name new variable created vr logical variable","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_not.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Logical NOT — var_not","text":"Survey object","code":""},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/reference/var_not.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Logical NOT — var_not","text":"","code":"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)                       │ #> └───────────┴──────────────┴────────────────────────────────────────────────┘ #>  var_not(\"Private insurance not used\", \"PAYPRIV\")"},{"path":"https://cdcgov.github.io/surveytable/news/index.html","id":"surveytable-development-version","dir":"Changelog","previous_headings":"","what":"surveytable (development version)","title":"surveytable (development version)","text":"Another public use data file use examples: rccsu2018. set_opts() replaces several functions setting options.","code":""},{"path":"https://cdcgov.github.io/surveytable/news/index.html","id":"surveytable-094","dir":"Changelog","previous_headings":"","what":"surveytable 0.9.4","title":"surveytable 0.9.4","text":"CRAN release: 2024-05-20 Optionally adjust p-values multiple comparisons (p_adjust argument)","code":""},{"path":"https://cdcgov.github.io/surveytable/news/index.html","id":"surveytable-093","dir":"Changelog","previous_headings":"","what":"surveytable 0.9.3","title":"surveytable 0.9.3","text":"codebook() Improved output. Allows unweighted survey data.frame. Can set certain options using argument. Tabulation functions show number observations. LaTeX printing.","code":""},{"path":"https://cdcgov.github.io/surveytable/news/index.html","id":"surveytable-092","dir":"Changelog","previous_headings":"","what":"surveytable 0.9.2","title":"surveytable 0.9.2","text":"CRAN release: 2024-01-18 Addressed CRAN comments.","code":""},{"path":"https://cdcgov.github.io/surveytable/news/index.html","id":"surveytable-091","dir":"Changelog","previous_headings":"","what":"surveytable 0.9.1","title":"surveytable 0.9.1","text":"Initial CRAN submission.","code":""}]
    diff --git a/docs/sitemap.xml b/docs/sitemap.xml
    index 0759860..42ff45e 100644
    --- a/docs/sitemap.xml
    +++ b/docs/sitemap.xml
    @@ -33,6 +33,9 @@
       
         https://cdcgov.github.io/surveytable/reference/codebook.html
       
    +  
    +    https://cdcgov.github.io/surveytable/reference/deprecated.html
    +  
       
         https://cdcgov.github.io/surveytable/reference/index.html
       
    @@ -46,10 +49,7 @@
         https://cdcgov.github.io/surveytable/reference/rccsu2018.html
       
       
    -    https://cdcgov.github.io/surveytable/reference/set_count_1k.html
    -  
    -  
    -    https://cdcgov.github.io/surveytable/reference/set_output.html
    +    https://cdcgov.github.io/surveytable/reference/set_opts.html
       
       
         https://cdcgov.github.io/surveytable/reference/set_survey.html
    diff --git a/inst/WORDLIST b/inst/WORDLIST
    index fce66af..1679e2f 100644
    --- a/inst/WORDLIST
    +++ b/inst/WORDLIST
    @@ -29,3 +29,5 @@ et
     importsurvey
     jss
     knowns
    +lpe
    +nchs
    diff --git a/man/deprecated.Rd b/man/deprecated.Rd
    new file mode 100644
    index 0000000..8d71476
    --- /dev/null
    +++ b/man/deprecated.Rd
    @@ -0,0 +1,26 @@
    +% Generated by roxygen2: do not edit by hand
    +% Please edit documentation in R/deprecated.R
    +\name{deprecated}
    +\alias{deprecated}
    +\alias{set_mode}
    +\alias{set_count_1k}
    +\alias{set_count_int}
    +\alias{set_output}
    +\title{Deprecated functions}
    +\usage{
    +set_mode(mode = "general")
    +
    +set_count_1k()
    +
    +set_count_int()
    +
    +set_output(drop_na = NULL, max_levels = NULL, csv = NULL)
    +}
    +\description{
    +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
    +}
    +\details{
    +Use \code{\link[=set_opts]{set_opts()}} instead of any of the following: \code{set_mode()}, \code{set_count_1k()},
    +\code{set_count_int()}, \code{set_output()}.
    +}
    +\keyword{internal}
    diff --git a/man/figures/lifecycle-archived.svg b/man/figures/lifecycle-archived.svg
    new file mode 100644
    index 0000000..745ab0c
    --- /dev/null
    +++ b/man/figures/lifecycle-archived.svg
    @@ -0,0 +1,21 @@
    +
    +    lifecycle: archived
    +    
    +        
    +        
    +    
    +    
    +        
    +    
    +    
    +        
    +        
    +        
    +    
    +    
    +        
    +        lifecycle
    +        
    +        archived
    +    
    +
    diff --git a/man/figures/lifecycle-defunct.svg b/man/figures/lifecycle-defunct.svg
    new file mode 100644
    index 0000000..d5c9559
    --- /dev/null
    +++ b/man/figures/lifecycle-defunct.svg
    @@ -0,0 +1,21 @@
    +
    +    lifecycle: defunct
    +    
    +        
    +        
    +    
    +    
    +        
    +    
    +    
    +        
    +        
    +        
    +    
    +    
    +        
    +        lifecycle
    +        
    +        defunct
    +    
    +
    diff --git a/man/figures/lifecycle-deprecated.svg b/man/figures/lifecycle-deprecated.svg
    new file mode 100644
    index 0000000..b61c57c
    --- /dev/null
    +++ b/man/figures/lifecycle-deprecated.svg
    @@ -0,0 +1,21 @@
    +
    +    lifecycle: deprecated
    +    
    +        
    +        
    +    
    +    
    +        
    +    
    +    
    +        
    +        
    +        
    +    
    +    
    +        
    +        lifecycle
    +        
    +        deprecated
    +    
    +
    diff --git a/man/figures/lifecycle-experimental.svg b/man/figures/lifecycle-experimental.svg
    new file mode 100644
    index 0000000..5d88fc2
    --- /dev/null
    +++ b/man/figures/lifecycle-experimental.svg
    @@ -0,0 +1,21 @@
    +
    +    lifecycle: experimental
    +    
    +        
    +        
    +    
    +    
    +        
    +    
    +    
    +        
    +        
    +        
    +    
    +    
    +        
    +        lifecycle
    +        
    +        experimental
    +    
    +
    diff --git a/man/figures/lifecycle-maturing.svg b/man/figures/lifecycle-maturing.svg
    new file mode 100644
    index 0000000..897370e
    --- /dev/null
    +++ b/man/figures/lifecycle-maturing.svg
    @@ -0,0 +1,21 @@
    +
    +    lifecycle: maturing
    +    
    +        
    +        
    +    
    +    
    +        
    +    
    +    
    +        
    +        
    +        
    +    
    +    
    +        
    +        lifecycle
    +        
    +        maturing
    +    
    +
    diff --git a/man/figures/lifecycle-questioning.svg b/man/figures/lifecycle-questioning.svg
    new file mode 100644
    index 0000000..7c1721d
    --- /dev/null
    +++ b/man/figures/lifecycle-questioning.svg
    @@ -0,0 +1,21 @@
    +
    +    lifecycle: questioning
    +    
    +        
    +        
    +    
    +    
    +        
    +    
    +    
    +        
    +        
    +        
    +    
    +    
    +        
    +        lifecycle
    +        
    +        questioning
    +    
    +
    diff --git a/man/figures/lifecycle-soft-deprecated.svg b/man/figures/lifecycle-soft-deprecated.svg
    new file mode 100644
    index 0000000..9c166ff
    --- /dev/null
    +++ b/man/figures/lifecycle-soft-deprecated.svg
    @@ -0,0 +1,21 @@
    +
    +    lifecycle: soft-deprecated
    +    
    +        
    +        
    +    
    +    
    +        
    +    
    +    
    +        
    +        
    +        
    +    
    +    
    +        
    +        lifecycle
    +        
    +        soft-deprecated
    +    
    +
    diff --git a/man/figures/lifecycle-stable.svg b/man/figures/lifecycle-stable.svg
    new file mode 100644
    index 0000000..9bf21e7
    --- /dev/null
    +++ b/man/figures/lifecycle-stable.svg
    @@ -0,0 +1,29 @@
    +
    +    lifecycle: stable
    +    
    +        
    +        
    +    
    +    
    +        
    +    
    +    
    +        
    +        
    +        
    +    
    +    
    +        
    +        
    +      lifecycle
    +    
    +        
    +        
    +      stable
    +    
    +    
    +
    diff --git a/man/figures/lifecycle-superseded.svg b/man/figures/lifecycle-superseded.svg
    new file mode 100644
    index 0000000..db8d757
    --- /dev/null
    +++ b/man/figures/lifecycle-superseded.svg
    @@ -0,0 +1,21 @@
    +
    +    lifecycle: superseded
    +    
    +        
    +        
    +    
    +    
    +        
    +    
    +    
    +        
    +        
    +        
    +    
    +    
    +        
    +        lifecycle
    +        
    +        superseded
    +    
    +
    diff --git a/man/set_count_1k.Rd b/man/set_count_1k.Rd
    deleted file mode 100644
    index ba7526c..0000000
    --- a/man/set_count_1k.Rd
    +++ /dev/null
    @@ -1,39 +0,0 @@
    -% Generated by roxygen2: do not edit by hand
    -% Please edit documentation in R/set_count.R
    -\name{set_count_1k}
    -\alias{set_count_1k}
    -\alias{set_count_int}
    -\title{Rounding counts}
    -\usage{
    -set_count_1k()
    -
    -set_count_int()
    -}
    -\value{
    -(Nothing.)
    -}
    -\description{
    -Determines how counts should be rounded.
    -}
    -\details{
    -\itemize{
    -\item \code{set_count_1k()}: round counts to the nearest 1,000.
    -\item \code{set_count_int()}: round counts to the nearest integer.
    -}
    -}
    -\examples{
    -set_survey(namcs2019sv)
    -set_count_int()
    -total()
    -
    -set_count_1k()
    -total()
    -}
    -\seealso{
    -Other options: 
    -\code{\link{set_output}()},
    -\code{\link{set_survey}()},
    -\code{\link{show_options}()},
    -\code{\link{surveytable-options}}
    -}
    -\concept{options}
    diff --git a/man/set_opts.Rd b/man/set_opts.Rd
    new file mode 100644
    index 0000000..f330de3
    --- /dev/null
    +++ b/man/set_opts.Rd
    @@ -0,0 +1,76 @@
    +% Generated by roxygen2: do not edit by hand
    +% Please edit documentation in R/set_opts.R
    +\name{set_opts}
    +\alias{set_opts}
    +\alias{show_opts}
    +\title{Set certain options}
    +\usage{
    +set_opts(
    +  mode = NULL,
    +  count = NULL,
    +  lpe = NULL,
    +  drop_na = NULL,
    +  max_levels = NULL,
    +  csv = NULL
    +)
    +
    +show_opts()
    +}
    +\arguments{
    +\item{mode}{\code{"general"} or \code{"NCHS"}. See below for details.}
    +
    +\item{count}{round counts to the nearest: integer (\code{"int"}) or one thousand (\code{"1k"})}
    +
    +\item{lpe}{identify low-precision estimates?}
    +
    +\item{drop_na}{drop missing values (\code{NA})? Categorical variables only.}
    +
    +\item{max_levels}{a categorical variable can have at most this many levels. Used to avoid printing huge tables.}
    +
    +\item{csv}{name of a CSV file or \code{""} to turn off CSV output}
    +}
    +\value{
    +(Nothing.)
    +}
    +\description{
    +\code{set_opts()} sets certain options. \code{show_opts()} shows the options that have
    +been set. More advanced users can also use \code{\link[=options]{options()}} and \code{\link[=show_options]{show_options()}} for
    +more detailed control.
    +}
    +\details{
    +If you are not setting a particular option, leave it as \code{NULL}.
    +
    +\code{mode} can be either \code{"general"} or \code{"NCHS"} and has the following meaning:
    +\itemize{
    +\item \code{"general"}:
    +\itemize{
    +\item Round counts to the nearest integer -- same as \code{count = "int"}.
    +\item Do not look for low-precision estimates -- same as \code{lpe = FALSE}.
    +\item Percentage CI's: use standard Korn-Graubard CI's.
    +}
    +\item \code{"nchs"}:
    +\itemize{
    +\item Round counts to the nearest 1,000 -- same as \code{count = "1k"}.
    +\item Identify low-precision estimates -- same as \code{lpe = TRUE}.
    +\item Percentage CI's: adjust Korn-Graubard CI's for the number of degrees of
    +freedom, matching the SUDAAN calculation.
    +}
    +}
    +}
    +\examples{
    +# Send output to a CSV file:
    +file_name = tempfile(fileext = ".csv")
    +suppressMessages( set_opts(csv = file_name) )
    +set_survey(namcs2019sv)
    +tab("AGER")
    +set_opts(csv = "") # Turn off CSV output
    +
    +show_opts()
    +}
    +\seealso{
    +Other options: 
    +\code{\link{set_survey}()},
    +\code{\link{show_options}()},
    +\code{\link{surveytable-options}}
    +}
    +\concept{options}
    diff --git a/man/set_output.Rd b/man/set_output.Rd
    deleted file mode 100644
    index 6e8a04d..0000000
    --- a/man/set_output.Rd
    +++ /dev/null
    @@ -1,38 +0,0 @@
    -% Generated by roxygen2: do not edit by hand
    -% Please edit documentation in R/set_output.R
    -\name{set_output}
    -\alias{set_output}
    -\alias{show_output}
    -\title{Set output defaults}
    -\usage{
    -set_output(drop_na = NULL, max_levels = NULL, csv = NULL)
    -
    -show_output()
    -}
    -\arguments{
    -\item{drop_na}{drop missing values (\code{NA})? Categorical variables only.}
    -
    -\item{max_levels}{a categorical variable can have at most this many levels. Used to avoid printing huge tables.}
    -
    -\item{csv}{name of a CSV file or "" to turn off CSV output}
    -}
    -\value{
    -(Nothing.)
    -}
    -\description{
    -\code{show_output()} shows the current defaults.
    -}
    -\examples{
    -tmp_file = tempfile(fileext = ".csv")
    -suppressMessages( set_output(csv = tmp_file) )
    -tab("AGER")
    -set_output(csv = "") # Turn off CSV output
    -}
    -\seealso{
    -Other options: 
    -\code{\link{set_count_1k}()},
    -\code{\link{set_survey}()},
    -\code{\link{show_options}()},
    -\code{\link{surveytable-options}}
    -}
    -\concept{options}
    diff --git a/man/set_survey.Rd b/man/set_survey.Rd
    index b4ae8ed..4deff94 100644
    --- a/man/set_survey.Rd
    +++ b/man/set_survey.Rd
    @@ -1,24 +1,21 @@
     % Generated by roxygen2: do not edit by hand
    -% Please edit documentation in R/set_survey.R, R/set_mode.R
    +% Please edit documentation in R/set_survey.R
     \name{set_survey}
     \alias{set_survey}
    -\alias{set_mode}
     \title{Specify the survey to analyze}
     \usage{
    -set_survey(design, mode = "default", csv = getOption("surveytable.csv"))
    -
    -set_mode(mode = "default")
    +set_survey(design, csv = getOption("surveytable.csv"), ...)
     }
     \arguments{
     \item{design}{either a survey object (created with \code{\link[survey:svydesign]{survey::svydesign()}} or
     \code{\link[survey:svrepdesign]{survey::svrepdesign()}}); or, for an unweighted survey, a \code{data.frame}.}
     
    -\item{mode}{set certain options. See below.}
    -
     \item{csv}{name of a CSV file}
    +
    +\item{...}{arguments to \code{\link[=set_opts]{set_opts()}}.}
     }
     \value{
    -\code{set_survey}: info about the survey. \code{set_mode}: nothing.
    +info about the survey
     }
     \description{
     You must specify a survey before the other functions, such as \code{\link[=tab]{tab()}},
    @@ -29,32 +26,14 @@ or \code{\link[survey:svrepdesign]{survey::svrepdesign()}}.
     Optionally, the survey can have an attribute called \code{label}, which is the
     long name of the survey. Optionally, each variable in the survey can have an
     attribute called \code{label}, which is the variable's long name.
    -
    -If you are not sure what the \code{mode} should be, leave it as \code{"default"}. Here is
    -what \code{mode} does:
    -\itemize{
    -\item \code{"general"} or \code{"default"}:
    -\itemize{
    -\item Round counts to the nearest integer -- see \code{\link[=set_count_int]{set_count_int()}}.
    -\item Do not look for low-precision estimates.
    -\item Percentage CI's: use standard Korn-Graubard CI's.
    -}
    -\item \code{"nchs"}:
    -\itemize{
    -\item Round counts to the nearest 1,000 -- see \code{\link[=set_count_1k]{set_count_1k()}}.
    -\item Identify low-precision estimates.
    -\item Percentage CI's: adjust Korn-Graubard CI's for the number of degrees of freedom, matching the SUDAAN calculation.
    -}
    -}
     }
     \examples{
     set_survey(namcs2019sv)
    -set_mode("general")
    +set_survey(namcs2019sv, mode = "general")
     }
     \seealso{
     Other options: 
    -\code{\link{set_count_1k}()},
    -\code{\link{set_output}()},
    +\code{\link{set_opts}()},
     \code{\link{show_options}()},
     \code{\link{surveytable-options}}
     }
    diff --git a/man/show_options.Rd b/man/show_options.Rd
    index 4acbcc6..0eb2e1a 100644
    --- a/man/show_options.Rd
    +++ b/man/show_options.Rd
    @@ -20,8 +20,7 @@ show_options()
     }
     \seealso{
     Other options: 
    -\code{\link{set_count_1k}()},
    -\code{\link{set_output}()},
    +\code{\link{set_opts}()},
     \code{\link{set_survey}()},
     \code{\link{surveytable-options}}
     }
    diff --git a/man/surveytable-options.Rd b/man/surveytable-options.Rd
    index ab2bf09..55e3609 100644
    --- a/man/surveytable-options.Rd
    +++ b/man/surveytable-options.Rd
    @@ -12,8 +12,8 @@ notable options.
     \subsection{Low-precision estimates.}{
     
     Optionally, all of the tabulation functions can identify low-precision estimates.
    -To turn on this functionality, either set the \code{surveytable.find_lpe} option to \code{TRUE},
    -or call \code{\link[=set_survey]{set_survey()}} or \code{\link[=set_mode]{set_mode()}} with the argument \code{mode = "NCHS"}.
    +Turn on this functionality using any of the following: \link{set_opts}(lpe = TRUE),
    +\link{set_opts}(mode = "nchs"), \link{set_survey}(*, mode = "nchs"), or \code{options(surveytable.find_lpe = TRUE)}.
     
     By default, low-precision estimates are identified using National Center for
     Health Statistics (NCHS) algorithms. However, this can be changed, as described
    @@ -23,8 +23,8 @@ Here is a description of the options related to the identification of low-precis
     estimates.
     \itemize{
     \item \code{surveytable.find_lpe}: should the tabulation functions look for low-precision
    -estimates? You can change this directly with \code{options()} or with the \code{mode} argument
    -to \code{\link[=set_survey]{set_survey()}} or \code{\link[=set_mode]{set_mode()}}.
    +estimates? You can change this directly with \code{options()} or with either \code{\link[=set_opts]{set_opts()}}
    +or \code{\link[=set_survey]{set_survey()}}.
     \item \code{surveytable.lpe_n}, \code{surveytable.lpe_counts}, \code{surveytable.lpe_percents}: names
     of 3 functions.
     }
    @@ -78,8 +78,7 @@ Useful links:
     
     
     Other options: 
    -\code{\link{set_count_1k}()},
    -\code{\link{set_output}()},
    +\code{\link{set_opts}()},
     \code{\link{set_survey}()},
     \code{\link{show_options}()}
     }
    diff --git a/man/svyciprop_adjusted.Rd b/man/svyciprop_adjusted.Rd
    index 15026ea..dbe04ad 100644
    --- a/man/svyciprop_adjusted.Rd
    +++ b/man/svyciprop_adjusted.Rd
    @@ -38,12 +38,12 @@ Written by Makram Talih in 2019.
     
     \code{df_method}: for \code{"default"}, \code{df = degf(design)}; for \code{"NHIS"}, \code{df = nrow(design) - 1}.
     
    -To use this function in tabulations, call \code{\link[=set_survey]{set_survey()}} or \code{\link[=set_mode]{set_mode()}} with the
    +To use this function in tabulations, call \code{\link[=set_survey]{set_survey()}} or \code{\link[=set_opts]{set_opts()}} with the
     \code{mode = "NCHS"} argument, or type: \code{options(surveytable.adjust_svyciprop = TRUE)}.
     }
     \examples{
     set_survey(namcs2019sv)
    -set_mode("NCHS")
    +set_opts(mode = "NCHS")
     tab("AGER")
    -set_mode("general")
    +set_opts(mode = "general")
     }
    diff --git a/vignettes/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.Rmd b/vignettes/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.Rmd
    index f0123ae..fbf6516 100644
    --- a/vignettes/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.Rmd
    +++ b/vignettes/Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.Rmd
    @@ -37,7 +37,7 @@ Check the survey name, survey design variables, and the number of observations t
     For this example, we do want to turn on certain NCHS-specific options, such as identifying low-precision estimates. If you do not care about identifying low-precision estimates, you can skip this command. To turn on the NCHS-specific options:
     
     ```{r, results='asis'}
    -set_mode("NCHS")
    +set_opts(mode = "NCHS")
     ```
     
     # Table 1
    @@ -231,17 +231,18 @@ In addition, for each age-sex category, the published table shows the percentage
     
     To calculate these percentages, a slightly more involved `for` loop is needed. Below is the code, followed by an explanation:
     
    -```{r}
    -tmp_file = tempfile(fileext = ".csv")
    -suppressMessages( set_output(csv = tmp_file) )
    +```r
    +set_opts(csv = "output.csv")
    +```
     
    +```{r}
     for (vr in c("AGER", "Age group", "SEX", "Age x Sex")) {
     	var_cross("tmp", "MAJOR", vr)
     	for (lvl in levels(surveytable:::env$survey$variables[,vr])) {
     		tab_subset("SPECCAT", "tmp", paste0("Preventive care: ", lvl))
     	}
     }
    -set_output(csv = "")
    +set_opts(csv = "")
     ```
     
     * Since `tab_subset()` is called from within a `for` loop, if we wanted to print to the screen, we would need to use `print( tab_subset(*) )`. Since we don't want to print to the screen, a call to `print()` is omitted.
    diff --git a/vignettes/Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report.Rmd b/vignettes/Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report.Rmd
    index 09c1f22..934ed20 100644
    --- a/vignettes/Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report.Rmd
    +++ b/vignettes/Example-Residential-Care-Community-Services-User-NSLTCP-RCC-SU-report.Rmd
    @@ -37,7 +37,7 @@ Check the survey name, survey design variables, and the number of observations t
     For this example, we do want to turn on certain NCHS-specific options, such as identifying low-precision estimates. If you do not care about identifying low-precision estimates, you can skip this command. To turn on the NCHS-specific options:
     
     ```{r, results='asis'}
    -set_mode("NCHS")
    +set_opts(mode = "NCHS")
     ```
     
     Alternatively, you can combine these two commands into a single command, like so:
    diff --git a/vignettes/surveytable.Rmd b/vignettes/surveytable.Rmd
    index e2d5338..ebaac90 100644
    --- a/vignettes/surveytable.Rmd
    +++ b/vignettes/surveytable.Rmd
    @@ -124,7 +124,7 @@ Check the survey label, survey design variables, and the number of observations
     For this example, we do want to turn on certain NCHS-specific options, such as identifying low-precision estimates. If you do not care about identifying low-precision estimates, you can skip this command. To turn on the NCHS-specific options:
     
     ```{r, results='asis'}
    -set_mode("NCHS")
    +set_opts(mode = "NCHS")
     ```
     
     ## List variables
    @@ -158,15 +158,20 @@ For each level of the variable, the table shows:
     * the estimated count, its standard error, and its 95% confidence interval; and 
     * the estimated percentage, its standard error, and its 95% confidence interval.
     
    -**NCHS presentation standards.** The `tab()` function also applies the National Center for Health Statistics (NCHS) presentation standards for counts and percentages, and flags estimates if, according to the standards, they should be suppressed, footnoted, or reviewed by an analyst. The CIs that are displayed are the ones that are used by the NCHS presentation standards. Specifically, for counts, the tables show the log Student's t 95% CI, with adaptations for complex surveys; for percentages, they show the 95% Korn and Graubard CI.
    +**Low-precision estimates.** Optionally, the `tab()` function, as well as the other tabulation functions that are discussed below, can automatically identify low-precision estimates using algorithms developed at NCHS. For counts, rates, and percentages, the functions flag estimates if, according to the algorithms, they should not be presented, should be reviewed by a clearance official, or should be presented with a footnote. If no estimates are flagged by the checks, the table has a footnote that indicates this. If the checks do identify an estimate, that is denoted in an additional column and in the table footnote.
     
    -One does not need to do anything extra to perform presentation standards checking -- it is performed automatically. For example, let's tabulate `PAYNOCHG`: 
    +Turn on this functionality using any of the following: `set_opts(lpe = TRUE)`,
    +`set_opts(mode = "nchs")`, `set_survey(*, mode = "nchs")`, or `options(surveytable.find_lpe = TRUE)`.
    +
    +As an example, let's tabulate `PAYNOCHG`: 
     
     ```{r, results='asis'}
     tab("PAYNOCHG")
     ```
     
    -This table tells us that, according to the NCHS presentation standards, the estimated number of visits in which there was no charge for the visit should be suppressed due to low precision. However, the lack of a percentage flag indicates that the estimated percentage of such visits can be shown. 
    +This table tells us that the estimated number of visits in which there was no charge for the visit has low precision. Intuitively, we can see that the CI for this count estimate is very wide, indicating high uncertainty. 
    +
    +The CIs that are displayed are the ones that are used by the NCHS presentation standards. Specifically, for counts, the tables show the log Student's t 95% CI, with adaptations for complex surveys; for percentages, they show the 95% Korn and Graubard CI.
     
     **Drop missing values.** Some variables might contain missing values (`NA`). Consider the following variable, which is not part of the actual survey, but was constructed specifically for this example:
     
    @@ -437,18 +442,15 @@ Here, the `AGER` variable remains unchanged, while the `Age group` variable has
     
     # Save the output
     
    -The `tab*` and `total*` functions have an argument called `csv` that specifies the name of a comma-separated values (CSV) file to save the output to. Alternatively, you can name the default CSV output file using the `set_output()` function. For example, the following directs `surveytable` to send all future output to a CSV file, create some tables, and then turn off sending output to the file:
    +The `tab*` and `total*` functions have an argument called `csv` that specifies the name of a comma-separated values (CSV) file to save the output to. Alternatively, you can name the default CSV output file using the `set_opts()` function. For example, the following directs `surveytable` to send all future output to a CSV file, create some tables, and then turn off sending output to the file:
     
     ```r
    -set_output(csv = "output.csv")
    +set_opts(csv = "output.csv")
     ```
     
     ```{r, results='asis'}
    -tab("MDDO", "SPECCAT", "MSA")
    -```
    -
    -```{r}
    -set_output(csv = "")
    +tab("MDDO")
    +set_opts(csv = "")
     ```
     
     If the tabulation functions are called from within an R Markdown notebook or a Quarto document, they produce HTML or LaTeX tables, as appropriate. This makes it easy to incorporate the output of the `surveytable` package directly into documents, presentations, "shiny" web apps, and other output types.