diff --git a/R/var_list.R b/R/var_list.R index 9fe4a18..3c54aba 100644 --- a/R/var_list.R +++ b/R/var_list.R @@ -31,7 +31,7 @@ var_list = function(sw = "", all=FALSE Variable = ii , Class = paste(class(design$variables[,ii]) , collapse = ", ") - , Label = .getvarname(design, ii) + , `Long name` = .getvarname(design, ii) ) ret %<>% rbind(r1) } diff --git a/README.Rmd b/README.Rmd index 7352a92..0bbf679 100644 --- a/README.Rmd +++ b/README.Rmd @@ -18,11 +18,7 @@ knitr::opts_chunk$set( -In R, the standard way of analyzing complex surveys is using the `survey` package. The major purpose of the `surveytable` package is to ease the use of the `survey` package in certain applications. `surveytable` improves the output of `survey` functions (by formatting and tabulating it); performs hypothesis tests; reduces the number of commands that users need to execute; and applies presentation standards to estimates, which is the usual practice at the National Center for Health Statistics (NCHS). - -The `surveytable` package allows users to use simple commands and produces formatted tabulated output. One useful function, which operates on categorical and logical variables, tabulates estimated counts and percentages with their standard errors and confidence intervals. It applies presentation standards for counts and percentages, and flags estimates if they should be suppressed, footnoted, or reviewed. Other functions list the variables in a survey, estimate the total population, tabulate survey subsets and variable interactions, tabulate numeric variables, calculate rates, perform t-tests, and save the output. - -The `surveytable` package is easier to use than using `survey` directly. With fewer commands, `surveytable` output has survey name, variable labels, formatted estimates, cleaner category values, both count and percentage estimates in a single table, and confidence intervals. The package also performs checking for presentation standards. +The `surveytable` package provides short and understandable commands that generate tabulated, formatted, and rounded survey estimates. One useful function, which operates on categorical and logical variables, tabulates estimated counts and percentages with their standard errors and confidence intervals. Other functions list the variables in a survey, estimate the total population, tabulate survey subsets and variable interactions, tabulate numeric variables, tabulate rates, create or modify survey variables, perform t-tests, and save the output. All of the tabulation functions check the NCHS presentation standards to flag low-precision estimates. If the `surveytable` code is called from an R Markdown notebook or a Quarto document, it generates HTML tables, which can be incorporated directly into documents. ## Installation diff --git a/README.md b/README.md index 88722f4..31bb14f 100644 --- a/README.md +++ b/README.md @@ -6,30 +6,18 @@ -In R, the standard way of analyzing complex surveys is using the -`survey` package. The major purpose of the `surveytable` package is to -ease the use of the `survey` package in certain applications. -`surveytable` improves the output of `survey` functions (by formatting -and tabulating it); performs hypothesis tests; reduces the number of -commands that users need to execute; and applies presentation standards -to estimates, which is the usual practice at the National Center for -Health Statistics (NCHS). - -The `surveytable` package allows users to use simple commands and -produces formatted tabulated output. One useful function, which operates -on categorical and logical variables, tabulates estimated counts and -percentages with their standard errors and confidence intervals. It -applies presentation standards for counts and percentages, and flags -estimates if they should be suppressed, footnoted, or reviewed. Other -functions list the variables in a survey, estimate the total population, -tabulate survey subsets and variable interactions, tabulate numeric -variables, calculate rates, perform t-tests, and save the output. - -The `surveytable` package is easier to use than using `survey` directly. -With fewer commands, `surveytable` output has survey name, variable -labels, formatted estimates, cleaner category values, both count and -percentage estimates in a single table, and confidence intervals. The -package also performs checking for presentation standards. +The `surveytable` package provides short and understandable commands +that generate tabulated, formatted, and rounded survey estimates. One +useful function, which operates on categorical and logical variables, +tabulates estimated counts and percentages with their standard errors +and confidence intervals. Other functions list the variables in a +survey, estimate the total population, tabulate survey subsets and +variable interactions, tabulate numeric variables, tabulate rates, +create or modify survey variables, perform t-tests, and save the output. +All of the tabulation functions check the NCHS presentation standards to +flag low-precision estimates. If the `surveytable` code is called from +an R Markdown notebook or a Quarto document, it generates HTML tables, +which can be incorporated directly into documents. ## Installation diff --git a/docs/articles/a01-Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html b/docs/articles/a01-Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html index eb8a3f5..d133d79 100644 --- a/docs/articles/a01-Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html +++ b/docs/articles/a01-Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html @@ -868,7 +868,7 @@

Counts and percentages -Label +Long.name diff --git a/docs/articles/a02-Example-Residential-Care-Community-RCC-Services-User-SU.html b/docs/articles/a02-Example-Residential-Care-Community-RCC-Services-User-SU.html index 0202e17..1994244 100644 --- a/docs/articles/a02-Example-Residential-Care-Community-RCC-Services-User-SU.html +++ b/docs/articles/a02-Example-Residential-Care-Community-RCC-Services-User-SU.html @@ -139,7 +139,7 @@

Figure 1 -Label +Long.name @@ -356,7 +356,7 @@

Figure 1 -Label +Long.name diff --git a/docs/articles/a03-Example-National-Ambulatory-Medical-Care-Survey-NAMCS-report.html b/docs/articles/a03-Example-National-Ambulatory-Medical-Care-Survey-NAMCS-report.html index 0cb2544..b7b2eb5 100644 --- a/docs/articles/a03-Example-National-Ambulatory-Medical-Care-Survey-NAMCS-report.html +++ b/docs/articles/a03-Example-National-Ambulatory-Medical-Care-Survey-NAMCS-report.html @@ -2472,7 +2472,7 @@

Figure 4 and Table 4 -Label +Long.name @@ -2504,7 +2504,7 @@

Figure 4 and Table 4 -Label +Long.name @@ -2997,7 +2997,7 @@

Figure 4 and Table 4 -Label +Long.name diff --git a/docs/articles/surveytable.html b/docs/articles/surveytable.html index 6ba7c49..9575d85 100644 --- a/docs/articles/surveytable.html +++ b/docs/articles/surveytable.html @@ -82,8 +82,9 @@ -

surveytable provides easy commands that generate -tabulated and formatted survey estimates.

+

The surveytable package provides short and +understandable commands that generate tabulated, formatted, and rounded +survey estimates.

The examples below use the National Ambulatory Medical Care Survey (NAMCS) 2019 Public Use File (PUF). NAMCS is “an annual nationally representative sample survey of visits to nonfederal office-based @@ -143,7 +144,7 @@

List variables -Label +Long.name diff --git a/docs/index.html b/docs/index.html index fad68e9..3e09fc9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -73,9 +73,7 @@

-

In R, the standard way of analyzing complex surveys is using the survey package. The major purpose of the surveytable package is to ease the use of the survey package in certain applications. surveytable improves the output of survey functions (by formatting and tabulating it); performs hypothesis tests; reduces the number of commands that users need to execute; and applies presentation standards to estimates, which is the usual practice at the National Center for Health Statistics (NCHS).

-

The surveytable package allows users to use simple commands and produces formatted tabulated output. One useful function, which operates on categorical and logical variables, tabulates estimated counts and percentages with their standard errors and confidence intervals. It applies presentation standards for counts and percentages, and flags estimates if they should be suppressed, footnoted, or reviewed. Other functions list the variables in a survey, estimate the total population, tabulate survey subsets and variable interactions, tabulate numeric variables, calculate rates, perform t-tests, and save the output.

-

The surveytable package is easier to use than using survey directly. With fewer commands, surveytable output has survey name, variable labels, formatted estimates, cleaner category values, both count and percentage estimates in a single table, and confidence intervals. The package also performs checking for presentation standards.

+

The surveytable package provides short and understandable commands that generate tabulated, formatted, and rounded survey estimates. One useful function, which operates on categorical and logical variables, tabulates estimated counts and percentages with their standard errors and confidence intervals. Other functions list the variables in a survey, estimate the total population, tabulate survey subsets and variable interactions, tabulate numeric variables, tabulate rates, create or modify survey variables, perform t-tests, and save the output. All of the tabulation functions check the NCHS presentation standards to flag low-precision estimates. If the surveytable code is called from an R Markdown notebook or a Quarto document, it generates HTML tables, which can be incorporated directly into documents.

Installation

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 5f0f008..eb297db 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -6,7 +6,7 @@ articles: a02-Example-Residential-Care-Community-RCC-Services-User-SU: a02-Example-Residential-Care-Community-RCC-Services-User-SU.html a03-Example-National-Ambulatory-Medical-Care-Survey-NAMCS-report: a03-Example-National-Ambulatory-Medical-Care-Survey-NAMCS-report.html surveytable: surveytable.html -last_built: 2023-11-13T23:50Z +last_built: 2023-11-16T22:48Z urls: reference: https://cdcgov.github.io/surveytable/reference article: https://cdcgov.github.io/surveytable/articles diff --git a/docs/reference/var_list.html b/docs/reference/var_list.html index a253c43..1c497a8 100644 --- a/docs/reference/var_list.html +++ b/docs/reference/var_list.html @@ -109,7 +109,7 @@

Examplesvar_list("age") #> Variables beginning with 'age' {NAMCS 2019 PUF} #> +----------------------------------------------------------------+ -#> ¦ Variable ¦ Class ¦ Label ¦ +#> ¦ Variable ¦ Class ¦ Long.name ¦ #> +-----------+---------+------------------------------------------¦ #> ¦ AGE ¦ numeric ¦ Patient age in years (raw - use caution) ¦ #> +-----------+---------+------------------------------------------¦ diff --git a/docs/search.json b/docs/search.json index 86210ff..9e3942b 100644 --- a/docs/search.json +++ b/docs/search.json @@ -1 +1 @@ -[{"path":"https://cdcgov.github.io/surveytable/articles/a01-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. Check survey name, survey design variables, number observations verify looks correct.","code":"library(surveytable) mysurvey = vars2019 # Or, if nchsdata has been installed, # mysurvey = nchsdata::namcs2019 set_survey(\"mysurvey\") ## _ ## Survey name NAMCS 2019 PUF ## Number of variables 36 ## Number of observations 8250 ## Stratified 1 - level Cluster Sampling design (with replacement) ## With (398) clusters. ## svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, ## data = d1) ## * To adjust how counts are rounded, see ?set_count_int"},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/articles/a01-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/a01-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} Recall survey design objects element called variables, data frame contains survey variables. Let’s examine levels MSA. calculate rates particular variable, need provide data frame variable called Level matches levels variable survey. Population gives population estimate. example, MSA, 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) levels(mysurvey$variables$MSA) ## [1] \"MSA (Metropolitan Statistical Area)\" \"Non-MSA\" 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/a01-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/a01-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/a01-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 syntax. (survey imported R using importsurvey package, automatically detects binary variables imports logical variables.) Recall survey design objects element called variables, data frame contains survey variables. Notes: ’re using within() function simplify syntax. nopwu = payment used, private, Medicare, etc. Self-pay (real) = self-pay used payment used. 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 (real) {NAMCS 2019 PUF} charge (real) {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":"mysurvey$variables = within(mysurvey$variables, { `Medicare and Medicaid` = PAYMCARE & PAYMCAID `Unknown or blank` = PAYDK | (NOPAY == \"No categories marked\") nopwu = !( PAYPRIV | PAYMCARE | PAYMCAID | PAYWKCMP | PAYOTH | PAYDK) `Self-pay (real)` = PAYSELF & nopwu `No charge (real)` = PAYNOCHG & nopwu `No insurance` = `Self-pay (real)` | `No charge (real)` }) tab(\"PAYPRIV\", \"PAYMCARE\", \"PAYMCAID\", \"Medicare and Medicaid\" , \"No insurance\", \"Self-pay (real)\", \"No charge (real)\" , \"PAYWKCMP\", \"PAYOTH\", \"Unknown or blank\")"},{"path":"https://cdcgov.github.io/surveytable/articles/a01-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/a01-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. variable Age group already created previous example. 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} (Patient age recode) x (Patient 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} (Patient age recode) x (Patient sex) (Major reason visit = Preventive care) {NAMCS 2019 PUF}","code":"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\")) { tab_subset(vr, \"MAJOR\", \"Preventive care\") }"},{"path":"https://cdcgov.github.io/surveytable/articles/a01-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 many tables produced, output sent CSV file, printed screen. , 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 , screen output turned back . run code, tables stored CSV file. give idea tables look like, just one tables: Type specialty (Primary, Medical, Surgical) ((Major reason visit) x (Patient age recode) = Preventive care : 15 years) {NAMCS 2019 PUF} match percentage published table, see “Primary care specialty” row. sure check presentation standards flags.","code":"set_output(csv = \"out.csv\", screen = FALSE) for (vr in c(\"AGER\", \"Age group\", \"SEX\", \"Age x Sex\")) { var_cross(\"tmp\", \"MAJOR\", vr) for (lvl in levels(mysurvey$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 = \"\", screen = TRUE) ## * Turning off CSV output. ## * Sending output to the screen. ## * ?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(mysurvey$variables[,vr])[1] tab_subset(\"SPECCAT\", \"tmp\", paste0(\"Preventive care : \", lvl))"},{"path":"https://cdcgov.github.io/surveytable/articles/a02-Example-Residential-Care-Community-RCC-Services-User-SU.html","id":"begin","dir":"Articles","previous_headings":"","what":"Begin","title":"Example: Residential Care Community (RCC) Services User (SU)","text":"Begin loading surveytable package. , print message explaining specify survey ’d like analyze. omitting message . Now, specify survey ’d like analyze. Check survey name, survey design variables, number observations verify looks correct.","code":"library(surveytable) mysurvey = nchsdata::rccsu2018 set_survey(\"mysurvey\") #> _ #> Survey name RCC SU 2018 PUF #> Number of variables 81 #> Number of observations 904 #> Stratified Independent Sampling design #> svydesign(ids = ~1, strata = ~pufstrata2 + su_facid, fpc = ~pufpopfac2, #> weights = ~suwt, data = d1) #> * To adjust how counts are rounded, see ?set_count_int"},{"path":"https://cdcgov.github.io/surveytable/articles/a02-Example-Residential-Care-Community-RCC-Services-User-SU.html","id":"figure-1","dir":"Articles","previous_headings":"","what":"Figure 1","title":"Example: Residential Care Community (RCC) Services User (SU)","text":"figure shows percentage residents sex, race / ethnicity, age group. Let’s find race / ethnicity variable: 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. Now, let’s take look age variable: Variables beginning ‘age’ {RCC SU 2018 PUF} age2 numeric variable. need create categorical variable based numeric variable. done using var_cut function. now variables needed figure. Let’s tabulate : Resident’s gender {RCC SU 2018 PUF} Resident’s race/ethnicity {RCC SU 2018 PUF} Age {RCC SU 2018 PUF}","code":"var_list(\"race\") tab(\"raceeth2\") var_collapse(\"raceeth2\", \"Another race or ethnicity\", c(\"Hispanic\", \"Other\")) var_list(\"age\") var_cut(\"Age\", \"age2\" , c(-Inf, 64, 74, 84, Inf) , c(\"Under 65\", \"65-74\", \"75-84\", \"85 and over\") ) tab(\"sex\", \"raceeth2\", \"Age\")"},{"path":"https://cdcgov.github.io/surveytable/articles/a02-Example-Residential-Care-Community-RCC-Services-User-SU.html","id":"figure-2","dir":"Articles","previous_headings":"","what":"Figure 2","title":"Example: Residential Care Community (RCC) Services User (SU)","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 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/a02-Example-Residential-Care-Community-RCC-Services-User-SU.html","id":"figure-4","dir":"Articles","previous_headings":"","what":"Figure 4","title":"Example: Residential Care Community (RCC) Services User (SU)","text":"(Figure 3 slightly involved, ’ll next.) figure shows percentage residents one select set chronic conditions. addition, shows distribution residents number conditions. 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} Now, count many chronic conditions present. Recall survey design objects element called variables, data frame contains survey variables. generating figure, create categorical variable based num_cc, numeric. Number chronic conditions {RCC SU 2018 PUF}","code":"tab(\"hbp\") tab(\"hbp\", \"alz\", \"depress\", \"arth\", \"diabetes\", \"heartdise\", \"osteo\" , \"copd\", \"stroke\", \"cancer\" , drop_na = TRUE) mysurvey$variables$num_cc = 0 for (vr in c(\"hbp\", \"alz\", \"depress\", \"arth\", \"diabetes\", \"heartdise\", \"osteo\" , \"copd\", \"stroke\", \"cancer\")) { idx = which(mysurvey$variables[,vr]) mysurvey$variables$num_cc[idx] = mysurvey$variables$num_cc[idx] + 1 } 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/a02-Example-Residential-Care-Community-RCC-Services-User-SU.html","id":"figure-3","dir":"Articles","previous_headings":"","what":"Figure 3","title":"Example: Residential Care Community (RCC) Services User (SU)","text":"figure shows percentage residents need help one activities daily living (ADLs). addition, shows distribution residents number ADLs need help. presented figure, ADLs, resident either need help. words, figure, ’s binary variable. Let’s take look levels one ADLs variables, exists survey: Several levels correspond resident needing help, one level = need help, one level = unknown. Let’s convert ADLs variables logical variables (called tmp ) immediately tabulate logical variables. addition, let’s count many ADLs present: 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} generating figure, create categorical variable based num_adl, numeric. Number ADLs {RCC SU 2018 PUF}","code":"levels(mysurvey$variables$bathhlp) #> [1] \"MISSING\" #> [2] \"NEED HELP OR SUPERVISION FROM ANOTHER PERSON\" #> [3] \"USE OF AN ASSISTIVE DEVICE\" #> [4] \"BOTH\" #> [5] \"NEED NO ASSISTANCE\" vrs = c(\"bathhlp\", \"walkhlp\", \"dreshlp\", \"transhlp\", \"toilhlp\", \"eathlp\") mysurvey$variables$num_adl = 0 for (vr in vrs) { mysurvey$variables$tmp = NA mysurvey$variables$tmp[which(mysurvey$variables[,vr] %in% c(\"NEED HELP OR SUPERVISION FROM ANOTHER PERSON\" , \"USE OF AN ASSISTIVE DEVICE\" , \"BOTH\"))] = TRUE mysurvey$variables$tmp[which(mysurvey$variables[,vr] == \"NEED NO ASSISTANCE\")] = FALSE # If neither TRUE nor FALSE, stays as NA (unknown). # Transfer the variable label attr(mysurvey$variables$tmp, \"label\") = attr(mysurvey$variables[,vr], \"label\") # Percentages based on knowns only tab(\"tmp\", drop_na = TRUE) # Count idx = which(mysurvey$variables$tmp) mysurvey$variables$num_adl[idx] = mysurvey$variables$num_adl[idx] + 1 } var_cut(\"Number of ADLs\", \"num_adl\" , c(-Inf, 0, 2, 6, Inf) , c(\"0\", \"1-2\", \"3-6\", \"??\")) tab(\"Number of ADLs\")"},{"path":"https://cdcgov.github.io/surveytable/articles/a03-Example-National-Ambulatory-Medical-Care-Survey-NAMCS-report.html","id":"begin","dir":"Articles","previous_headings":"","what":"Begin","title":"Example: National Ambulatory Medical Care Survey (NAMCS) report","text":"Begin loading surveytable package. , print message explaining specify survey ’d like analyze. omitting message . Now, specify survey ’d like analyze. Check survey name, survey design variables, number observations verify looks correct.","code":"library(surveytable) mysurvey = nchsdata::namcs2019 set_survey(\"mysurvey\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 1100 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int"},{"path":"https://cdcgov.github.io/surveytable/articles/a03-Example-National-Ambulatory-Medical-Care-Survey-NAMCS-report.html","id":"figure-1-and-table-1","dir":"Articles","previous_headings":"","what":"Figure 1 and Table 1","title":"Example: National Ambulatory Medical Care Survey (NAMCS) report","text":"figure table show rate visits, overall, age group, sex. First, let’s convert numeric variable AGE categorical variable categories used figure. Converting numeric variable categorical variable done var_cut function. Given population estimates available uspop2019, calculate rates: Total (rate per 100 population) {NAMCS 2019 PUF} Age group 5 (rate per 100 population) {NAMCS 2019 PUF} Patient sex (rate per 100 population) {NAMCS 2019 PUF}","code":"var_cut(\"Age group 5\", \"AGE\" , c(-Inf, 0, 17, 44, 64, Inf) , c(\"Under 1\", \"1-17\", \"18-44\", \"45-64\", \"65 and over\")) total_rate(uspop2019$total) tab_rate(\"Age group 5\", uspop2019$`Age group 5`) tab_rate(\"SEX\", uspop2019$SEX)"},{"path":"https://cdcgov.github.io/surveytable/articles/a03-Example-National-Ambulatory-Medical-Care-Survey-NAMCS-report.html","id":"figure-2-and-table-2","dir":"Articles","previous_headings":"","what":"Figure 2 and Table 2","title":"Example: National Ambulatory Medical Care Survey (NAMCS) report","text":"figure shows distribution primary expected source payment, tests whether pairs percentages equal. table shows info age group. First, let’s examine levels PAYTYPER (Type payment). Recall survey design objects element called variables, data frame contains survey variables. published figure, “Self-pay” “charge/Charity” combined category called “insurance”. Additionally, categories shown published figure, combine category called “etc”. Let’s combine categories: Now, tabulate variable, testing equality levels: Type payment (recoded multiple sources using hierarchy) {NAMCS 2019 PUF} Comparison possible pairs Type payment (recoded multiple sources using hierarchy) {NAMCS 2019 PUF} can ignore results “etc” category, since ’s shown figure. Note presentation flags “insurance” category. second table indicates differences statistically significant. replicate table, need variable age categories – categories different ones created . Thus, create another age category variable, tabulate subsets: Type payment (recoded multiple sources using hierarchy) (Age group = 18) {NAMCS 2019 PUF} Type payment (recoded multiple sources using hierarchy) (Age group = 18-64) {NAMCS 2019 PUF} Type payment (recoded multiple sources using hierarchy) (Age group = 65 ) {NAMCS 2019 PUF} , note presentation flags. flags concerned counts – since published table show counts, relevant. However, 18-64 age group, “insurance” category flagged.","code":"levels(mysurvey$variables$PAYTYPER) #> [1] \"All sources of payment are blank\" #> [2] \"Unknown\" #> [3] \"Private insurance\" #> [4] \"Medicare\" #> [5] \"Medicaid, CHIP or other state-based program\" #> [6] \"Worker's compensation\" #> [7] \"Self-pay\" #> [8] \"No charge/Charity\" #> [9] \"Other\" var_collapse(\"PAYTYPER\", \"No insurance\" , c(\"Self-pay\", \"No charge/Charity\")) var_collapse(\"PAYTYPER\", \"etc\" , c(\"All sources of payment are blank\", \"Unknown\" , \"Worker's compensation\", \"Other\") ) tab(\"PAYTYPER\", test = TRUE) var_cut(\"Age group\", \"AGE\" , c(-Inf, 17, 64, Inf) , c(\"Under 18\", \"18-64\", \"65 and over\")) tab_subset(\"PAYTYPER\", \"Age group\")"},{"path":"https://cdcgov.github.io/surveytable/articles/a03-Example-National-Ambulatory-Medical-Care-Survey-NAMCS-report.html","id":"figure-3-and-table-3","dir":"Articles","previous_headings":"","what":"Figure 3 and Table 3","title":"Example: National Ambulatory Medical Care Survey (NAMCS) report","text":"figure shows major reason visit. data system variable called MAJOR (Major reason visit), exactly variable shown figure. Rather, variable shown figure constructed two variables: MAJOR INJURY (visit related injury/trauma, …). Specifically, visit injury visit (indicated INJURY), figure counts . Otherwise, injury visit, figure counts according value MAJOR. addition, figure collapses levels MAJOR. Let’s begin collapsing levels MAJOR, match figure: Create new variable, called Reason. Initialize NA. Copy values MAJOR Reason “Blank” – MAJOR “Blank”, Reason becomes NA. Since ’ll combining two factor variables, easy solution convert character , convert back factor later. Now, let’s incorporate INJURY variable. Order matters! first added MAJOR, INJURY. Since INJURY added second, trumps value MAJOR. want. Since figure based knowns , use drop_na argument ignore missing values (NA): Reason (knowns ) {NAMCS 2019 PUF} Comparison possible pairs Reason (knowns ) {NAMCS 2019 PUF} table shows information, age group: Reason (Age group = 18) (knowns ) {NAMCS 2019 PUF} Reason (Age group = 18-64) (knowns ) {NAMCS 2019 PUF} Reason (Age group = 65 ) (knowns ) {NAMCS 2019 PUF}","code":"levels(mysurvey$variables$MAJOR) #> [1] \"Blank\" #> [2] \"New problem (less than 3 mos. onset)\" #> [3] \"Chronic problem, routine\" #> [4] \"Chronic problem, flare-up\" #> [5] \"Pre-surgery\" #> [6] \"Post-surgery\" #> [7] \"Preventive care\" var_collapse(\"MAJOR\", \"Pre- and postsurgery\" , c(\"Pre-surgery\", \"Post-surgery\")) var_collapse(\"MAJOR\", \"Chronic\" , c(\"Chronic problem, routine\", \"Chronic problem, flare-up\")) idx = which( mysurvey$variables$MAJOR != \"Blank\" ) mysurvey$variables$Reason[idx] = as.character( mysurvey$variables$MAJOR[idx] ) levels(mysurvey$variables$INJURY) #> [1] \"Blank\" \"Unknown\" #> [3] \"No\" \"Yes\" #> [5] \"Questionable injury status\" idx = which(mysurvey$variables$INJURY == \"Yes\") mysurvey$variables$Reason[idx] = \"Injury\" mysurvey$variables$Reason = as.factor(mysurvey$variables$Reason) tab(\"Reason\", drop_na = TRUE, test = TRUE) tab_subset(\"Reason\", \"Age group\", drop_na = TRUE)"},{"path":"https://cdcgov.github.io/surveytable/articles/a03-Example-National-Ambulatory-Medical-Care-Survey-NAMCS-report.html","id":"figure-4-and-table-4","dir":"Articles","previous_headings":"","what":"Figure 4 and Table 4","title":"Example: National Ambulatory Medical Care Survey (NAMCS) report","text":"figure shows percentage visits selected services ordered provided (mutually exclusive). table shows information age. Laboratory tests. survey several binary variables indicating whether certain laboratory test ordered provided. variables TRUE, counts laboratory test visit. Variables beginning ‘bmp’ {NAMCS 2019 PUF} Variables beginning ‘cbc’ {NAMCS 2019 PUF} create variable TRUE variable list TRUE, use var_any function: Laboratory tests {NAMCS 2019 PUF} variables. Three variables figure follow logic. Let’s create tabulate now. Health education {NAMCS 2019 PUF} Imaging services {NAMCS 2019 PUF} Procedures {NAMCS 2019 PUF} Examinations screenings. Examinations screenings little bit involved. variables , TRUE number variables TRUE. However, also TRUE another situation. five DIAGx.unformatted variables contain diagnosis codes. : Variables beginning ‘diag’ {NAMCS 2019 PUF} diagnosis codes begins either “Z0” “Z1”, Examinations screenings also TRUE. begin, let’s create logical variables true diagnosis codes begin either “Z0” “Z1”: Now, can use var_any list variables original survey, plus variables just created: Examinations screenings {NAMCS 2019 PUF} Table. published table shows age. many tables created, let’s send CSV file instead screen:","code":"var_list(\"bmp\") var_list(\"cbc\") var_any(\"Laboratory tests\" , c(\"BMP\", \"CBC\", \"CHLAMYD\", \"CMP\", \"CREAT\", \"BLDCX\", \"TRTCX\" , \"URNCX\", \"OTHCX\", \"GLUCOSE\", \"GCT\", \"HGBA\", \"HEPTEST\" , \"HIVTEST\", \"HPVDNA\", \"CHOLEST\", \"HEPATIC\", \"PAP\" , \"PREGTEST\", \"PSA\", \"STREP\", \"THYROID\", \"URINE\", \"VITD\")) tab(\"Laboratory tests\") var_any(\"Health education\" , c(\"ETOHED\", \"ASTHMAED\", \"ASTHMAP\", \"DIAEDUC\", \"DIETNUTR\", \"EXERCISE\" ,\"FAMPLAN\", \"GENETIC\", \"GRWTHDEV\", \"INJPREV\", \"STDPREV\", \"STRESMGT\" , \"SUBSTED\", \"TOBACED\", \"WTREDUC\")) tab(\"Health education\") var_any(\"Imaging services\" , c(\"ANYIMAGE\", \"BONEDENS\", \"CATSCAN\", \"ECHOCARD\", \"OTHULTRA\", \"MAMMO\" , \"MRI\", \"XRAY\", \"OTHIMAGE\") ) tab(\"Imaging services\") var_any(\"Procedures\" , c(\"AUDIO\", \"BIOPSY\", \"CARDIAC\", \"COLON\", \"CRYO\", \"EKG\", \"EEG\", \"EMG\", \"EXCISION\", \"FETAL\", \"PEAK\", \"SIGMOID\", \"SPIRO\", \"TONO\", \"TBTEST\", \"EGD\")) tab(\"Procedures\") var_list(\"diag\") for (ii in 1:5) { vr = paste0(\"DIAG\", ii, \".unformatted\") newvr = paste0(\"Z_DIAG\", ii) mysurvey$variables[,newvr] = ( startsWith(mysurvey$variables[,vr], \"Z0\") | startsWith(mysurvey$variables[,vr], \"Z1\")) } var_any(\"Examinations and screenings\" # Variables from the original survey , c(\"ETOH\", \"BREAST\", \"DEPRESS\", \"DVS\", \"FOOT\", \"NEURO\" , \"PELVIC\", \"RECTAL\", \"RETINAL\", \"SKIN\", \"SUBST\" # Newly created variables , \"Z_DIAG1\", \"Z_DIAG2\", \"Z_DIAG3\", \"Z_DIAG4\", \"Z_DIAG5\")) tab(\"Examinations and screenings\") set_output(csv = \"out.csv\", screen = FALSE) for (vr in c(\"Laboratory tests\", \"Health education\", \"Imaging services\" , \"Procedures\", \"Examinations and screenings\")) { tab_subset(vr, \"Age group\") } set_output(csv = \"\", screen = TRUE) #> * Turning off CSV output. #> * Sending output to the screen. #> * ?set_output for other options."},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"begin","dir":"Articles","previous_headings":"","what":"Begin","title":"Introduction to surveytable","text":"Begin loading surveytable package. , print message explaining specify survey ’d like analyze. showing message . Now, specify survey ’d like analyze. Check survey label, survey design variables, number observations verify looks correct.","code":"library(surveytable) set_survey(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"list-variables","dir":"Articles","previous_headings":"Begin","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, categorical variable age groups, 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 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 (variable indicating whether charge physician visit): 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} Optionally, one levels subsetting variable can specified, tabulate subsets. title table reflects value subsetting variable (case, SEX). tab_subset command, table (, subset), percentages add 100%. Another way tabulate subsets using tab_cross function, crosses interacts two variables generates table using new variable. estimated counts produced tab_subset tab_cross , tab_cross, percentages across entire population add 100%. (Patient age recode) x (Patient sex) {NAMCS 2019 PUF}","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 tab_subset functions make easy perform design-based t-test using test argument.","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":"test whether levels AGER statistically similar different, type: Patient age recode {NAMCS 2019 PUF} Comparison possible pairs Patient age recode {NAMCS 2019 PUF} According , following pairs categories statistically similar: “25-44 years” “65-74 years”; “25-44 years” “75 years ”. pairs categories statistically different.","code":"tab(\"AGER\", test = TRUE)"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"categorical-variables-subset","dir":"Articles","previous_headings":"Perform statistical hypothesis testing","what":"Categorical variables (subset)","title":"Introduction to surveytable","text":"test whether levels AGER statistically similar different within subpopulations defined SEX variable, type: Patient age recode (Patient sex = Female) {NAMCS 2019 PUF} Comparison possible pairs Patient age recode (Patient sex = Female) {NAMCS 2019 PUF} Patient age recode (Patient sex = Male) {NAMCS 2019 PUF} Comparison possible pairs Patient age recode (Patient sex = Male) {NAMCS 2019 PUF} According , following pairs categories statistically similar: “25-44 years” “65-74 years”; “25-44 years” “75 years ”. “15 years” “25-44 years”; “15 years” “75 years ”; “25-44 years” “75 years ”; “65-74 years” “75 years ”.","code":"tab_subset(\"AGER\", \"SEX\", 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":"test whether numeric variable NUMMED varies categorical variable AGER, type: Number medications coded (different levels Patient age recode) {NAMCS 2019 PUF} Comparison Number medications coded across possible pairs Patient age recode {NAMCS 2019 PUF} According , NUMMED statistically similar “15 years” “15-24 years” AGER categories. statistically different pairs categories.","code":"tab_subset(\"NUMMED\", \"AGER\", 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 vars2019 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. 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} Suppose analyst interested preventive care visits. Instead tabulating levels MAJOR, type: 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, 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. 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. analyst might need something interacted variable, possibly subset later. create interacted variable, use var_cross command: Now, example, create table age / sex interaction preventive care visits: (Patient age recode) x (Patient sex) (Major reason visit = Preventive care) {NAMCS 2019 PUF} 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} variables data frame. Recall survey design objects element called variables, data frame contains survey variables. advanced users can create modify variables variables data frame directly.","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, 4, 14, 64, Inf) , c(\"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\") tab_subset(\"Age x Sex\", \"MAJOR\", \"Preventive care\") 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\") class(vars2019$variables) #> [1] \"data.frame\""},{"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 also argument called screen, TRUE default, determines whether output sent screen. many tables produced, user might choose turn screen printing, output CSV file. tabulation functions called within R Markdown notebook, produce HTML tables. makes easy incorporate output surveytable package directly documents, presentations, “shiny” web apps, output types. Finally, tabulation functions return tables produce, either data frame, list data frames. advanced analysts can use functionality integrate surveytable programming tasks.","code":"set_output(csv = \"out.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. https://cdcgov.github.io/surveytable, https://github.com/CDCgov/surveytable.","code":"@Manual{, title = {surveytable: Formatted Survey Estimates}, author = {Alex Strashny}, year = {2023}, note = {https://cdcgov.github.io/surveytable, https://github.com/CDCgov/surveytable}, }"},{"path":"https://cdcgov.github.io/surveytable/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Welcome!","title":"Welcome!","text":"Thank contributing CDC’s Open Source projects! questions doubts, don’t afraid send way. appreciate contributions, looking forward fostering open, transparent, collaborative environment. contributing, encourage also read LICENSE, README, code--conduct files, also found repository. inquiries questions answered content repository, feel free contact us.","code":""},{"path":"https://cdcgov.github.io/surveytable/CONTRIBUTING.html","id":"public-domain","dir":"","previous_headings":"","what":"Public Domain","title":"Welcome!","text":"project public domain within United States, copyright related rights work worldwide waived CC0 1.0 Universal public domain dedication. contributions project released CC0 dedication. submitting pull request agreeing comply waiver copyright interest.","code":""},{"path":"https://cdcgov.github.io/surveytable/CONTRIBUTING.html","id":"requesting-changes","dir":"","previous_headings":"","what":"Requesting Changes","title":"Welcome!","text":"pull request/merging process designed give CDC Surveillance Team space opportunity consider discuss suggested changes. policy affects CDC spaces, -line , users expected abide .","code":""},{"path":"https://cdcgov.github.io/surveytable/CONTRIBUTING.html","id":"open-an-issue-in-the-repository","dir":"","previous_headings":"Requesting Changes","what":"Open an issue in the repository","title":"Welcome!","text":"don’t specific language submit like suggest change something addressed, can open issue repository. Team members respond issue soon possible.","code":""},{"path":"https://cdcgov.github.io/surveytable/CONTRIBUTING.html","id":"submit-a-pull-request","dir":"","previous_headings":"Requesting Changes","what":"Submit a pull request","title":"Welcome!","text":"like contribute, please submit pull request. order us merge pull request, must: * least seven days old. Pull requests may held longer necessary give people opportunity assess . * Receive +1 majority team members associated request. significant dissent team, meeting held discuss plan action pull request.","code":""},{"path":"https://cdcgov.github.io/surveytable/DISCLAIMER.html","id":null,"dir":"","previous_headings":"","what":"DISCLAIMER","title":"DISCLAIMER","text":"Use service limited non-sensitive publicly available data. Users must use, share, store kind sensitive data like health status, provision payment healthcare, Personally Identifiable Information (PII) /Protected Health Information (PHI), etc. circumstance. Administrators service reserve right moderate information used, shared, stored service time. user abide disclaimer Code Conduct may subject action, including revoking access services. material embodied software provided “-” without warranty kind, express, implied otherwise, including without limitation, warranty fitness particular purpose. event shall Centers Disease Control Prevention (CDC) United States (U.S.) government liable anyone else direct, special, incidental, indirect consequential damages kind, damages whatsoever, including without limitation, loss profit, loss use, savings revenue, claims third parties, whether CDC U.S. government advised possibility loss, however caused theory liability, arising connection possession, use performance software.","code":""},{"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":"R, standard way analyzing complex surveys using survey package. major purpose surveytable package ease use survey package certain applications. surveytable improves output survey functions (formatting tabulating ); performs hypothesis tests; reduces number commands users need execute; applies presentation standards estimates, usual practice National Center Health Statistics (NCHS). surveytable package allows users use simple commands produces formatted tabulated output. One useful function, operates categorical logical variables, tabulates estimated counts percentages standard errors confidence intervals. applies presentation standards counts percentages, flags estimates suppressed, footnoted, reviewed. functions list variables survey, estimate total population, tabulate survey subsets variable interactions, tabulate numeric variables, calculate rates, perform t-tests, save output. surveytable package easier use using survey directly. fewer commands, surveytable output survey name, variable labels, formatted estimates, cleaner category values, count percentage estimates single table, confidence intervals. package also performs checking presentation standards.","code":""},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Formatted Survey Estimates","text":"can install surveytable like :","code":"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. Patient age recode {NAMCS 2019 PUF}","code":"library(surveytable) set_survey(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int tab(\"AGER\")"},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"related-packages","dir":"","previous_headings":"","what":"Related packages","title":"Formatted Survey Estimates","text":", 3 related packages: surveytable: functions tabulating survey estimates nchsdata: public use files (PUFs) National Center Health Statistics (NCHS) importsurvey: functions importing data R importsurvey imports surveys R currently formats. Public versions surveys already imported stored nchsdata. Tables estimates can generated using surveytable.","code":""},{"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 http://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 http://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 http://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":"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":"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":"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":"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":"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":"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":"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":"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":"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/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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int set_count_int() #> * Rounding counts to the nearest integer. #> * ?set_count_int for other options. total() #> Total {NAMCS 2019 PUF} #> +----------------------------------------------------------+ #> ¦ Number ¦ SE ¦ LL ¦ UL ¦ #> +---------------+------------+-------------+---------------¦ #> ¦ 1,036,484,356 ¦ 48,836,217 ¦ 945,013,590 ¦ 1,136,808,860 ¦ #> +----------------------------------------------------------+ #> (Checked presentation standards. Nothing to #> report.) #> set_count_1k() #> * Rounding counts to the nearest 1,000. #> * ?set_count_1k for other options. total() #> Total {NAMCS 2019 PUF} #> +---------------------------------------------------------------+ #> ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ #> +---------------+---------------+---------------+---------------¦ #> ¦ 1,036,484 ¦ 48,836 ¦ 945,014 ¦ 1,136,809 ¦ #> +---------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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(csv = NULL, screen = NULL, max_levels = 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":"csv name CSV file \"\" turn CSV output screen print screen? max_levels categorical variable can many levels. Used avoid printing huge tables.","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":"if (FALSE) { set_output(csv = \"out.csv\") show_output() } 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":"need specify survey functions, tab(), work.","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(survey_name = \"\") show_survey()"},{"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":"survey_name name survey.design object (quotation marks)","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":"(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":"show_survey() shows survey specified. Optionally, survey can attribute called label, long name survey. attribute set importsurvey package, can also set manually. Optionally, variable survey can attribute called label, variable's long name. attribute set haven importsurvey packages, can also set manually.","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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int show_survey() #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int"},{"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":"Show package 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.check_present #> [1] TRUE #> #> $surveytable.csv #> [1] \"\" #> #> $surveytable.drop_na #> [1] FALSE #> #> $surveytable.max_levels #> [1] 20 #> #> $surveytable.names_count #> [1] \"Number (000)\" \"SE (000)\" \"LL (000)\" \"UL (000)\" #> #> $surveytable.names_prct #> [1] \"Percent\" \"SE\" \"LL\" \"UL\" #> #> $surveytable.present_count #> [1] \".present_count\" #> #> $surveytable.present_prop #> [1] \".present_prop\" #> #> $surveytable.present_restricted #> [1] \".present_restricted\" #> #> $surveytable.rate_per #> [1] 100 #> #> $surveytable.screen #> [1] TRUE #> #> $surveytable.survey #> [1] \"vars2019\" #> #> $surveytable.survey_label #> [1] \"NAMCS 2019 PUF\" #> #> $surveytable.tx_count #> [1] \".tx_count_1k\" #> #> $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.","code":""},{"path":[]},{"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":"Formatted Survey Estimates.","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","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 design object subset expression specifying subpopulation label survey label newly created survey design 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 design 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(vars2019, AGE < 18, \"Children\") set_survey(\"children\") #> Error: children does not exist. Did you forget to load it? tab(\"AGER\") #> Patient age recode {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 117,917 ¦ 14,097 ¦ 93,229 ¦ 149,142 ¦ 11.4 ¦ 1.3 ¦ 8.9 ¦ 14.2 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 64,856 ¦ 7,018 ¦ 52,387 ¦ 80,292 ¦ 6.3 ¦ 0.6 ¦ 5.1 ¦ 7.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 170,271 ¦ 13,966 ¦ 144,925 ¦ 200,049 ¦ 16.4 ¦ 1.1 ¦ 14.3 ¦ 18.8 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 309,506 ¦ 23,290 ¦ 266,994 ¦ 358,787 ¦ 29.9 ¦ 1.4 ¦ 27.2 ¦ 32.6 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 206,866 ¦ 14,366 ¦ 180,481 ¦ 237,109 ¦ 20   ¦ 1.2 ¦ 17.6 ¦ 22.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 167,069 ¦ 15,179 ¦ 139,746 ¦ 199,735 ¦ 16.1 ¦ 1.3 ¦ 13.7 ¦ 18.8 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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\"), 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. df_method: \"default\", df = degf(design); \"NHIS\", df = nrow(design) - 1.","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. use function tabulations, 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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int options(surveytable.adjust_svyciprop = TRUE) tab(\"AGER\") #> Patient age recode {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 117,917 ¦ 14,097 ¦ 93,229 ¦ 149,142 ¦ 11.4 ¦ 1.3 ¦ 8.9 ¦ 14.2 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 64,856 ¦ 7,018 ¦ 52,387 ¦ 80,292 ¦ 6.3 ¦ 0.6 ¦ 5.1 ¦ 7.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 170,271 ¦ 13,966 ¦ 144,925 ¦ 200,049 ¦ 16.4 ¦ 1.1 ¦ 14.3 ¦ 18.8 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 309,506 ¦ 23,290 ¦ 266,994 ¦ 358,787 ¦ 29.9 ¦ 1.4 ¦ 27.2 ¦ 32.6 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 206,866 ¦ 14,366 ¦ 180,481 ¦ 237,109 ¦ 20   ¦ 1.2 ¦ 17.6 ¦ 22.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 167,069 ¦ 15,179 ¦ 139,746 ¦ 199,735 ¦ 16.1 ¦ 1.3 ¦ 13.7 ¦ 18.8 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> options(surveytable.adjust_svyciprop = FALSE) tab(\"AGER\") #> Patient age recode {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 117,917 ¦ 14,097 ¦ 93,229 ¦ 149,142 ¦ 11.4 ¦ 1.3 ¦ 8.9 ¦ 14.2 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 64,856 ¦ 7,018 ¦ 52,387 ¦ 80,292 ¦ 6.3 ¦ 0.6 ¦ 5.1 ¦ 7.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 170,271 ¦ 13,966 ¦ 144,925 ¦ 200,049 ¦ 16.4 ¦ 1.1 ¦ 14.3 ¦ 18.8 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 309,506 ¦ 23,290 ¦ 266,994 ¦ 358,787 ¦ 29.9 ¦ 1.4 ¦ 27.2 ¦ 32.6 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 206,866 ¦ 14,366 ¦ 180,481 ¦ 237,109 ¦ 20   ¦ 1.2 ¦ 17.6 ¦ 22.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 167,069 ¦ 15,179 ¦ 139,746 ¦ 199,735 ¦ 16.1 ¦ 1.3 ¦ 13.7 ¦ 18.8 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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, drop_na = getOption(\"surveytable.drop_na\"), max_levels = getOption(\"surveytable.max_levels\"), screen = getOption(\"surveytable.screen\"), 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 test? alpha significance level test. drop_na drop missing values (NA)? Categorical variables . max_levels categorical variable can many levels. Used avoid printing huge tables. screen print screen? 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 data.frame tables single data.frame 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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int tab(\"AGER\") #> Patient age recode {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 117,917 ¦ 14,097 ¦ 93,229 ¦ 149,142 ¦ 11.4 ¦ 1.3 ¦ 8.9 ¦ 14.2 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 64,856 ¦ 7,018 ¦ 52,387 ¦ 80,292 ¦ 6.3 ¦ 0.6 ¦ 5.1 ¦ 7.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 170,271 ¦ 13,966 ¦ 144,925 ¦ 200,049 ¦ 16.4 ¦ 1.1 ¦ 14.3 ¦ 18.8 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 309,506 ¦ 23,290 ¦ 266,994 ¦ 358,787 ¦ 29.9 ¦ 1.4 ¦ 27.2 ¦ 32.6 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 206,866 ¦ 14,366 ¦ 180,481 ¦ 237,109 ¦ 20   ¦ 1.2 ¦ 17.6 ¦ 22.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 167,069 ¦ 15,179 ¦ 139,746 ¦ 199,735 ¦ 16.1 ¦ 1.3 ¦ 13.7 ¦ 18.8 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> tab(\"MDDO\", \"SPECCAT\", \"MSA\") #> Type of doctor (MD or DO) {NAMCS 2019 PUF} #> +----------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+-----------+---------+-----+------+------¦ #> ¦ M.D. - Doctor ¦ 980,280 ¦ 48,388 ¦ 889,842 ¦ 1,079,910 ¦ 94.6 ¦ 0.7 ¦ 93.1 ¦ 95.8 ¦ #> ¦ of Medicine ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+-----------+---------+-----+------+------¦ #> ¦ D.O. - Doctor ¦ 56,204 ¦ 6,602 ¦ 44,597 ¦ 70,832 ¦ 5.4 ¦ 0.7 ¦ 4.2 ¦ 6.9 ¦ #> ¦ of Osteopathy ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +----------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> #> Type of specialty (Primary, Medical, Surgical) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Primary care ¦ 521,466 ¦ 31,136 ¦ 463,840 ¦ 586,252 ¦ 50.3 ¦ 2.6 ¦ 45.1 ¦ 55.5 ¦ #> ¦ specialty ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Surgical care ¦ 214,832 ¦ 31,110 ¦ 161,661 ¦ 285,490 ¦ 20.7 ¦ 3   ¦ 15.1 ¦ 27.3 ¦ #> ¦ specialty ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Medical care ¦ 300,186 ¦ 43,497 ¦ 225,806 ¦ 399,067 ¦ 29   ¦ 3.6 ¦ 22.1 ¦ 36.6 ¦ #> ¦ specialty ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> #> Metropolitan Statistical Area Status of physician location {NAMCS 2019 PUF} #> +----------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+-----------+---------+-----+------+------¦ #> ¦ MSA ¦ 973,676 ¦ 50,515 ¦ 879,490 ¦ 1,077,947 ¦ 93.9 ¦ 1.7 ¦ 89.6 ¦ 96.8 ¦ #> ¦ (Metropolitan ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> ¦ Statistical ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> ¦ Area) ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+-----------+---------+-----+------+------¦ #> ¦ Non-MSA ¦ 62,809 ¦ 17,549 ¦ 36,249 ¦ 108,830 ¦ 6.1 ¦ 1.7 ¦ 3.2 ¦ 10.4 ¦ #> +----------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> # 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 ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 117,917 ¦ 14,097 ¦ 93,229 ¦ 149,142 ¦ 11.4 ¦ 1.3 ¦ 8.9 ¦ 14.2 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 64,856 ¦ 7,018 ¦ 52,387 ¦ 80,292 ¦ 6.3 ¦ 0.6 ¦ 5.1 ¦ 7.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 170,271 ¦ 13,966 ¦ 144,925 ¦ 200,049 ¦ 16.4 ¦ 1.1 ¦ 14.3 ¦ 18.8 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 309,506 ¦ 23,290 ¦ 266,994 ¦ 358,787 ¦ 29.9 ¦ 1.4 ¦ 27.2 ¦ 32.6 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 206,866 ¦ 14,366 ¦ 180,481 ¦ 237,109 ¦ 20   ¦ 1.2 ¦ 17.6 ¦ 22.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 167,069 ¦ 15,179 ¦ 139,746 ¦ 199,735 ¦ 16.1 ¦ 1.3 ¦ 13.7 ¦ 18.8 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> #> 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 ¦ * ¦ #> +-----------------------------------------------------+ #> *: p-value <= 0.05 #> # Integrate the output into other programming tasks my_table = tab(\"AGER\", screen = FALSE) my_table = within(my_table, {RSE = `SE (000)` / `Number (000)`})"},{"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\"), screen = getOption(\"surveytable.screen\"), 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. screen print screen? 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 data.frame tables single data.frame 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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int # 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 ¦ Rate ¦ SE ¦ LL ¦ UL ¦ #> +----------------------------+-------+------+-------+-------¦ #> ¦ MSA (Metropolitan ¦ 351.2 ¦ 18.2 ¦ 317.2 ¦ 388.8 ¦ #> ¦ Statistical Area) ¦ ¦ ¦ ¦ ¦ #> +----------------------------+-------+------+-------+-------¦ #> ¦ Non-MSA ¦ 136.7 ¦ 38.2 ¦ 78.9 ¦ 236.8 ¦ #> +-----------------------------------------------------------+ #> (Checked presentation standards. Nothing to #> report.) #> # 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 ¦ Rate ¦ SE ¦ LL ¦ UL ¦ #> +----------------------------+-------+----+-------+-------¦ #> ¦ M.D. - Doctor of Medicine ¦ 303.3 ¦ 15 ¦ 275.3 ¦ 334.1 ¦ #> +----------------------------+-------+----+-------+-------¦ #> ¦ D.O. - Doctor of ¦ 17.4 ¦ 2 ¦ 13.8 ¦ 21.9 ¦ #> ¦ Osteopathy ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------+ #> (Checked presentation standards. Nothing to #> report.) #>"},{"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. Test equality proportions means.","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\"), screen = getOption(\"surveytable.screen\"), csv = getOption(\"surveytable.csv\") ) tab_subset( vr, vrby, lvls = c(), test = FALSE, alpha = 0.05, drop_na = getOption(\"surveytable.drop_na\"), max_levels = getOption(\"surveytable.max_levels\"), screen = getOption(\"surveytable.screen\"), 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. screen print screen? csv name CSV file lvls (optional) show levels vrby test perform hypothesis test? alpha significance level test. 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":"tab_subset: list data.frame tables single data.frame table. tab_cross: data.frame 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().","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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int # For each SEX, tabulate AGER tab_subset(\"AGER\", \"SEX\") #> Patient age recode (Patient sex = Female) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 59,958 ¦ 7,206 ¦ 47,318 ¦ 75,974 ¦ 9.9 ¦ 1.2 ¦ 7.6 ¦ 12.6 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 41,128 ¦ 4,532 ¦ 33,066 ¦ 51,156 ¦ 6.8 ¦ 0.7 ¦ 5.4 ¦ 8.4 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 113,708 ¦ 11,461 ¦ 93,256 ¦ 138,646 ¦ 18.8 ¦ 1.6 ¦ 15.8 ¦ 22.1 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 175,978 ¦ 16,009 ¦ 147,153 ¦ 210,450 ¦ 29.1 ¦ 1.7 ¦ 25.7 ¦ 32.6 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 120,099 ¦ 11,066 ¦ 100,171 ¦ 143,992 ¦ 19.8 ¦ 1.5 ¦ 17   ¦ 22.9 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 94,173 ¦ 11,085 ¦ 74,682 ¦ 118,751 ¦ 15.6 ¦ 1.5 ¦ 12.8 ¦ 18.7 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> #> Patient age recode (Patient sex = Male) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 57,959 ¦ 7,728 ¦ 44,570 ¦ 75,371 ¦ 13.4 ¦ 1.7 ¦ 10.3 ¦ 17.1 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 23,728 ¦ 4,344 ¦ 16,457 ¦ 34,210 ¦ 5.5 ¦ 0.8 ¦ 4   ¦ 7.4 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 56,562 ¦ 7,277 ¦ 43,861 ¦ 72,942 ¦ 13.1 ¦ 1.3 ¦ 10.7 ¦ 15.8 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 133,528 ¦ 12,956 ¦ 110,319 ¦ 161,619 ¦ 30.9 ¦ 1.6 ¦ 27.8 ¦ 34.3 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 86,766 ¦ 6,767 ¦ 74,409 ¦ 101,176 ¦ 20.1 ¦ 1.5 ¦ 17.3 ¦ 23.1 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 72,896 ¦ 6,661 ¦ 60,872 ¦ 87,296 ¦ 16.9 ¦ 1.5 ¦ 14   ¦ 20.2 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> # Same counts as tab_subset(), but different percentages. tab_cross(\"AGER\", \"SEX\") #> (Patient age recode) x (Patient sex) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 59,958 ¦ 7,206 ¦ 47,318 ¦ 75,974 ¦ 5.8 ¦ 0.7 ¦ 4.5 ¦ 7.3 ¦ #> ¦ years : ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> ¦ Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years : ¦ 41,128 ¦ 4,532 ¦ 33,066 ¦ 51,156 ¦ 4   ¦ 0.4 ¦ 3.2 ¦ 4.9 ¦ #> ¦ Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years : ¦ 113,708 ¦ 11,461 ¦ 93,256 ¦ 138,646 ¦ 11   ¦ 1   ¦ 9   ¦ 13.2 ¦ #> ¦ Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years : ¦ 175,978 ¦ 16,009 ¦ 147,153 ¦ 210,450 ¦ 17   ¦ 1.1 ¦ 14.8 ¦ 19.3 ¦ #> ¦ Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years : ¦ 120,099 ¦ 11,066 ¦ 100,171 ¦ 143,992 ¦ 11.6 ¦ 1   ¦ 9.7 ¦ 13.7 ¦ #> ¦ Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 94,173 ¦ 11,085 ¦ 74,682 ¦ 118,751 ¦ 9.1 ¦ 0.9 ¦ 7.3 ¦ 11.1 ¦ #> ¦ over : Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 57,959 ¦ 7,728 ¦ 44,570 ¦ 75,371 ¦ 5.6 ¦ 0.7 ¦ 4.3 ¦ 7.2 ¦ #> ¦ years : Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years : ¦ 23,728 ¦ 4,344 ¦ 16,457 ¦ 34,210 ¦ 2.3 ¦ 0.4 ¦ 1.6 ¦ 3.2 ¦ #> ¦ Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years : ¦ 56,562 ¦ 7,277 ¦ 43,861 ¦ 72,942 ¦ 5.5 ¦ 0.6 ¦ 4.3 ¦ 6.8 ¦ #> ¦ Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years : ¦ 133,528 ¦ 12,956 ¦ 110,319 ¦ 161,619 ¦ 12.9 ¦ 1   ¦ 10.9 ¦ 15.1 ¦ #> ¦ Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years : ¦ 86,766 ¦ 6,767 ¦ 74,409 ¦ 101,176 ¦ 8.4 ¦ 0.6 ¦ 7.2 ¦ 9.7 ¦ #> ¦ Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 72,896 ¦ 6,661 ¦ 60,872 ¦ 87,296 ¦ 7   ¦ 0.6 ¦ 5.9 ¦ 8.3 ¦ #> ¦ over : Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> # What are the levels or MAJOR? tab(\"MAJOR\") #> Major reason for this visit {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Blank ¦ 15,887 ¦ 3,354 ¦ 10,335 ¦ 24,419 ¦ 1.5 ¦ 0.3 ¦ 1   ¦ 2.3 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ New problem ¦ 275,014 ¦ 19,691 ¦ 238,955 ¦ 316,514 ¦ 26.5 ¦ 1.5 ¦ 23.7 ¦ 29.5 ¦ #> ¦ (less than 3 ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> ¦ mos. onset) ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Chronic ¦ 380,910 ¦ 35,080 ¦ 317,916 ¦ 456,386 ¦ 36.8 ¦ 2.5 ¦ 31.8 ¦ 41.9 ¦ #> ¦ problem, ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> ¦ routine ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Chronic ¦ 74,017 ¦ 9,329 ¦ 57,706 ¦ 94,939 ¦ 7.1 ¦ 0.9 ¦ 5.5 ¦ 9.1 ¦ #> ¦ problem, ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> ¦ flare-up ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Pre-surgery ¦ 12,864 ¦ 2,151 ¦ 9,188 ¦ 18,010 ¦ 1.2 ¦ 0.2 ¦ 0.9 ¦ 1.7 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Post-surgery ¦ 54,170 ¦ 6,749 ¦ 42,350 ¦ 69,289 ¦ 5.2 ¦ 0.7 ¦ 4   ¦ 6.7 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Preventive ¦ 223,624 ¦ 18,520 ¦ 190,068 ¦ 263,103 ¦ 21.6 ¦ 1.7 ¦ 18.3 ¦ 25.1 ¦ #> ¦ care ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> # Tabulate AGER by only 2 of the levels of MAJOR tab_subset(\"AGER\", \"MAJOR\" , lvls = c(\"Chronic problem, routine\", \"Chronic problem, flare-up\")) #> Patient age recode (Major reason for this visit = Chronic problem, routine) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 10,161 ¦ 1,941 ¦ 6,898 ¦ 14,966 ¦ 2.7 ¦ 0.5 ¦ 1.7 ¦ 4   ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 12,648 ¦ 2,365 ¦ 8,632 ¦ 18,534 ¦ 3.3 ¦ 0.7 ¦ 2.1 ¦ 4.9 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 48,324 ¦ 8,017 ¦ 34,763 ¦ 67,175 ¦ 12.7 ¦ 1.7 ¦ 9.5 ¦ 16.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 125,018 ¦ 14,947 ¦ 98,780 ¦ 158,225 ¦ 32.8 ¦ 2.1 ¦ 28.6 ¦ 37.2 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 92,148 ¦ 11,411 ¦ 72,189 ¦ 117,625 ¦ 24.2 ¦ 1.9 ¦ 20.5 ¦ 28.2 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 92,612 ¦ 12,722 ¦ 70,637 ¦ 121,422 ¦ 24.3 ¦ 2.5 ¦ 19.6 ¦ 29.6 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> #> Patient age recode (Major reason for this visit = Chronic problem, flare-up) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ Flags ¦ #> ¦ ¦ (000) ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +-------------+-------------+----------+----------+----------+---------+-----+------+------+--------¦ #> ¦ Under 15 ¦ 3,242 ¦ 1,303 ¦ 1,207 ¦ 8,706 ¦ 4.4 ¦ 1.8 ¦ 1.6 ¦ 9.4 ¦ Cx Px ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +-------------+-------------+----------+----------+----------+---------+-----+------+------+--------¦ #> ¦ 15-24 years ¦ 2,653 ¦ 713 ¦ 1,497 ¦ 4,705 ¦ 3.6 ¦ 1   ¦ 1.9 ¦ 6.1 ¦ ¦ #> +-------------+-------------+----------+----------+----------+---------+-----+------+------+--------¦ #> ¦ 25-44 years ¦ 10,733 ¦ 2,199 ¦ 7,022 ¦ 16,405 ¦ 14.5 ¦ 2.9 ¦ 9.1 ¦ 21.4 ¦ ¦ #> +-------------+-------------+----------+----------+----------+---------+-----+------+------+--------¦ #> ¦ 45-64 years ¦ 26,435 ¦ 4,930 ¦ 18,194 ¦ 38,408 ¦ 35.7 ¦ 4.3 ¦ 27.3 ¦ 44.9 ¦ ¦ #> +-------------+-------------+----------+----------+----------+---------+-----+------+------+--------¦ #> ¦ 65-74 years ¦ 19,642 ¦ 4,285 ¦ 12,605 ¦ 30,608 ¦ 26.5 ¦ 4.4 ¦ 18.1 ¦ 36.4 ¦ ¦ #> +-------------+-------------+----------+----------+----------+---------+-----+------+------+--------¦ #> ¦ 75 years ¦ 11,312 ¦ 2,615 ¦ 7,048 ¦ 18,156 ¦ 15.3 ¦ 2.7 ¦ 10.3 ¦ 21.5 ¦ ¦ #> ¦ and over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------------+ #> Cx: suppress count (and rate); Px: suppress percent #> # 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 with categorical variables tab_subset(\"AGER\", \"SEX\", test = TRUE) #> Patient age recode (Patient sex = Female) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 59,958 ¦ 7,206 ¦ 47,318 ¦ 75,974 ¦ 9.9 ¦ 1.2 ¦ 7.6 ¦ 12.6 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 41,128 ¦ 4,532 ¦ 33,066 ¦ 51,156 ¦ 6.8 ¦ 0.7 ¦ 5.4 ¦ 8.4 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 113,708 ¦ 11,461 ¦ 93,256 ¦ 138,646 ¦ 18.8 ¦ 1.6 ¦ 15.8 ¦ 22.1 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 175,978 ¦ 16,009 ¦ 147,153 ¦ 210,450 ¦ 29.1 ¦ 1.7 ¦ 25.7 ¦ 32.6 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 120,099 ¦ 11,066 ¦ 100,171 ¦ 143,992 ¦ 19.8 ¦ 1.5 ¦ 17   ¦ 22.9 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 94,173 ¦ 11,085 ¦ 74,682 ¦ 118,751 ¦ 15.6 ¦ 1.5 ¦ 12.8 ¦ 18.7 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> #> Comparison of all possible pairs of Patient age recode (Patient sex = Female) {NAMCS 2019 PUF} #> +-----------------------------------------------------+ #> ¦ Level 1 ¦ Level 2 ¦ p-value ¦ Flag ¦ #> +----------------+-------------------+---------+------¦ #> ¦ Under 15 years ¦ 15-24 years ¦ 0.01  ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ Under 15 years ¦ 25-44 years ¦ 0     ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ Under 15 years ¦ 45-64 years ¦ 0     ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ Under 15 years ¦ 65-74 years ¦ 0     ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ Under 15 years ¦ 75 years and over ¦ 0.007 ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ 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.677 ¦ ¦ #> +----------------+-------------------+---------+------¦ #> ¦ 25-44 years ¦ 75 years and over ¦ 0.201 ¦ ¦ #> +----------------+-------------------+---------+------¦ #> ¦ 45-64 years ¦ 65-74 years ¦ 0     ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ 45-64 years ¦ 75 years and over ¦ 0     ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ 65-74 years ¦ 75 years and over ¦ 0.034 ¦ * ¦ #> +-----------------------------------------------------+ #> *: p-value <= 0.05 #> #> Patient age recode (Patient sex = Male) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 57,959 ¦ 7,728 ¦ 44,570 ¦ 75,371 ¦ 13.4 ¦ 1.7 ¦ 10.3 ¦ 17.1 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 23,728 ¦ 4,344 ¦ 16,457 ¦ 34,210 ¦ 5.5 ¦ 0.8 ¦ 4   ¦ 7.4 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 56,562 ¦ 7,277 ¦ 43,861 ¦ 72,942 ¦ 13.1 ¦ 1.3 ¦ 10.7 ¦ 15.8 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 133,528 ¦ 12,956 ¦ 110,319 ¦ 161,619 ¦ 30.9 ¦ 1.6 ¦ 27.8 ¦ 34.3 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 86,766 ¦ 6,767 ¦ 74,409 ¦ 101,176 ¦ 20.1 ¦ 1.5 ¦ 17.3 ¦ 23.1 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 72,896 ¦ 6,661 ¦ 60,872 ¦ 87,296 ¦ 16.9 ¦ 1.5 ¦ 14   ¦ 20.2 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> #> Comparison of all possible pairs of Patient age recode (Patient sex = Male) {NAMCS 2019 PUF} #> +-----------------------------------------------------+ #> ¦ Level 1 ¦ Level 2 ¦ p-value ¦ Flag ¦ #> +----------------+-------------------+---------+------¦ #> ¦ Under 15 years ¦ 15-24 years ¦ 0     ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ Under 15 years ¦ 25-44 years ¦ 0.894 ¦ ¦ #> +----------------+-------------------+---------+------¦ #> ¦ Under 15 years ¦ 45-64 years ¦ 0     ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ Under 15 years ¦ 65-74 years ¦ 0.008 ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ Under 15 years ¦ 75 years and over ¦ 0.166 ¦ ¦ #> +----------------+-------------------+---------+------¦ #> ¦ 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.001 ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ 25-44 years ¦ 75 years and over ¦ 0.113 ¦ ¦ #> +----------------+-------------------+---------+------¦ #> ¦ 45-64 years ¦ 65-74 years ¦ 0     ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ 45-64 years ¦ 75 years and over ¦ 0     ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ 65-74 years ¦ 75 years and over ¦ 0.105 ¦ ¦ #> +-----------------------------------------------------+ #> *: p-value <= 0.05 #> # Hypothesis testing with numeric variables 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 ¦ #> +---------------------------------------------------+ #> #> 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 ¦ * ¦ #> +-----------------------------------------------------+ #> *: p-value <= 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\"), screen = getOption(\"surveytable.screen\"), 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. screen print screen? 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 data.frame tables single data.frame 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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int tab_subset_rate(\"AGER\", \"SEX\", uspop2019$`AGER x SEX`) #> Patient age recode (Patient sex = Female) (rate per 100 population) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------+ #> ¦ Level ¦ Rate ¦ SE ¦ LL ¦ UL ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ Under 15 years ¦ 202.5 ¦ 24.3 ¦ 159.8 ¦ 256.6 ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ 15-24 years ¦ 198.4 ¦ 21.9 ¦ 159.5 ¦ 246.8 ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ 25-44 years ¦ 263.3 ¦ 26.5 ¦ 215.9 ¦ 321   ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ 45-64 years ¦ 414   ¦ 37.7 ¦ 346.2 ¦ 495.1 ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ 65-74 years ¦ 720.3 ¦ 66.4 ¦ 600.8 ¦ 863.6 ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ 75 years and over ¦ 758.1 ¦ 89.2 ¦ 601.2 ¦ 956   ¦ #> +---------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> #> Patient age recode (Patient sex = Male) (rate per 100 population) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------+ #> ¦ Level ¦ Rate ¦ SE ¦ LL ¦ UL ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ Under 15 years ¦ 187.4 ¦ 25   ¦ 144.1 ¦ 243.7 ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ 15-24 years ¦ 113.1 ¦ 20.7 ¦ 78.4 ¦ 163   ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ 25-44 years ¦ 133.4 ¦ 17.2 ¦ 103.4 ¦ 172   ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ 45-64 years ¦ 333.4 ¦ 32.3 ¦ 275.4 ¦ 403.5 ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ 65-74 years ¦ 594.8 ¦ 46.4 ¦ 510.1 ¦ 693.6 ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ 75 years and over ¦ 801.2 ¦ 73.2 ¦ 669.1 ¦ 959.5 ¦ #> +---------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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( screen = getOption(\"surveytable.screen\"), 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":"screen print screen? 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":"data.frame","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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int total() #> Total {NAMCS 2019 PUF} #> +---------------------------------------------------------------+ #> ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ #> +---------------+---------------+---------------+---------------¦ #> ¦ 1,036,484 ¦ 48,836 ¦ 945,014 ¦ 1,136,809 ¦ #> +---------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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\"), screen = getOption(\"surveytable.screen\"), 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 screen print screen? 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":"data.frame","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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int total_rate(uspop2019$total) #> Total (rate per 100 population) {NAMCS 2019 PUF} #> +---------------------------------------------------------------+ #> ¦ Rate ¦ SE ¦ LL ¦ UL ¦ #> +---------------+---------------+---------------+---------------¦ #> ¦ 320.7 ¦ 15.1 ¦ 292.4 ¦ 351.7 ¦ #> +---------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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 noninstitutional 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/vars2019.html","id":null,"dir":"Reference","previous_headings":"","what":"Selected variables from the National Ambulatory Medical Care Survey (NAMCS) 2019 Public Use File (PUF) — vars2019","title":"Selected variables from the National Ambulatory Medical Care Survey (NAMCS) 2019 Public Use File (PUF) — vars2019","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/vars2019.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) — vars2019","text":"","code":"vars2019"},{"path":"https://cdcgov.github.io/surveytable/reference/vars2019.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) — vars2019","text":"object class survey.design2 (inherits survey.design) 8250 rows 36 columns.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/vars2019.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) — vars2019","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/vars2019.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) — vars2019","text":"survey design object 8,250 observations.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_any.html","id":null,"dir":"Reference","previous_headings":"","what":"Is any variable true? — var_any","title":"Is any variable true? — 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? — 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? — 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? — var_any","text":"(Nothing.)","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? — var_any","text":"","code":"set_survey(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int var_any(\"Imaging services\" , c(\"ANYIMAGE\", \"BONEDENS\", \"CATSCAN\", \"ECHOCARD\", \"OTHULTRA\" , \"MAMMO\", \"MRI\", \"XRAY\", \"OTHIMAGE\")) tab(\"Imaging services\") #> Imaging services {NAMCS 2019 PUF} #> +-------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +-------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ FALSE ¦ 901,115 ¦ 43,298 ¦ 820,085 ¦ 990,151 ¦ 86.9 ¦ 1.1 ¦ 84.6 ¦ 89.1 ¦ #> +-------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ TRUE ¦ 135,369 ¦ 13,574 ¦ 111,134 ¦ 164,890 ¦ 13.1 ¦ 1.1 ¦ 10.9 ¦ 15.4 ¦ #> +-------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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)"},{"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.","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":"(Nothing.)","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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 37 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int var_case(\"Preventive care visits\", \"MAJOR\", \"Preventive care\") tab(\"Preventive care visits\") #> Preventive care visits {NAMCS 2019 PUF} #> +-------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +-------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ FALSE ¦ 812,861 ¦ 45,220 ¦ 728,841 ¦ 906,566 ¦ 78.4 ¦ 1.7 ¦ 74.9 ¦ 81.7 ¦ #> +-------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ TRUE ¦ 223,624 ¦ 18,520 ¦ 190,068 ¦ 263,103 ¦ 21.6 ¦ 1.7 ¦ 18.3 ¦ 25.1 ¦ #> +-------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> var_case(\"Surgery-related visits\" , \"MAJOR\" , c(\"Pre-surgery\", \"Post-surgery\")) tab(\"Surgery-related visits\") #> Surgery-related visits {NAMCS 2019 PUF} #> +--------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +-------+--------------+----------+----------+-----------+---------+-----+------+------¦ #> ¦ FALSE ¦ 969,451 ¦ 47,976 ¦ 879,793 ¦ 1,068,246 ¦ 93.5 ¦ 0.8 ¦ 91.9 ¦ 94.9 ¦ #> +-------+--------------+----------+----------+-----------+---------+-----+------+------¦ #> ¦ TRUE ¦ 67,034 ¦ 7,810 ¦ 53,273 ¦ 84,348 ¦ 6.5 ¦ 0.8 ¦ 5.1 ¦ 8.1 ¦ #> +--------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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":"(Nothing.)","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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 39 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int tab(\"PRIMCARE\") #> Are you the patient's primary care provider? {NAMCS 2019 PUF} #> +----------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ Flags ¦ #> ¦ ¦ (000) ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------+-------------+----------+----------+----------+---------+-----+------+------+-------¦ #> ¦ Blank ¦ 1,150 ¦ 478 ¦ 440 ¦ 3,005 ¦ 0.1 ¦ 0   ¦ 0   ¦ 0.2 ¦ Cx ¦ #> +---------+-------------+----------+----------+----------+---------+-----+------+------+-------¦ #> ¦ Unknown ¦ 39,519 ¦ 9,507 ¦ 24,520 ¦ 63,692 ¦ 3.8 ¦ 0.9 ¦ 2.3 ¦ 6   ¦ ¦ #> +---------+-------------+----------+----------+----------+---------+-----+------+------+-------¦ #> ¦ Yes ¦ 383,481 ¦ 28,555 ¦ 331,362 ¦ 443,798 ¦ 37   ¦ 2.6 ¦ 31.9 ¦ 42.3 ¦ ¦ #> +---------+-------------+----------+----------+----------+---------+-----+------+------+-------¦ #> ¦ No ¦ 612,335 ¦ 43,282 ¦ 533,050 ¦ 703,413 ¦ 59.1 ¦ 2.5 ¦ 53.9 ¦ 64.1 ¦ ¦ #> +----------------------------------------------------------------------------------------------+ #> Cx: suppress count (and rate) #> var_collapse(\"PRIMCARE\", \"Unknown if PCP\", c(\"Blank\", \"Unknown\")) tab(\"PRIMCARE\") #> Are you the patient's primary care provider? {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Unknown if ¦ 40,669 ¦ 9,479 ¦ 25,619 ¦ 64,560 ¦ 3.9 ¦ 0.9 ¦ 2.4 ¦ 6.1 ¦ #> ¦ PCP ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Yes ¦ 383,481 ¦ 28,555 ¦ 331,362 ¦ 443,798 ¦ 37   ¦ 2.6 ¦ 31.9 ¦ 42.3 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ No ¦ 612,335 ¦ 43,282 ¦ 533,050 ¦ 703,413 ¦ 59.1 ¦ 2.5 ¦ 53.9 ¦ 64.1 ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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":"(Nothing.)","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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 39 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int 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 ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 117,917 ¦ 14,097 ¦ 93,229 ¦ 149,142 ¦ 11.4 ¦ 1.3 ¦ 8.9 ¦ 14.2 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 64,856 ¦ 7,018 ¦ 52,387 ¦ 80,292 ¦ 6.3 ¦ 0.6 ¦ 5.1 ¦ 7.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 170,271 ¦ 13,966 ¦ 144,925 ¦ 200,049 ¦ 16.4 ¦ 1.1 ¦ 14.3 ¦ 18.8 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 309,506 ¦ 23,290 ¦ 266,994 ¦ 358,787 ¦ 29.9 ¦ 1.4 ¦ 27.2 ¦ 32.6 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 206,866 ¦ 14,366 ¦ 180,481 ¦ 237,109 ¦ 20   ¦ 1.2 ¦ 17.6 ¦ 22.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 167,069 ¦ 15,179 ¦ 139,746 ¦ 199,735 ¦ 16.1 ¦ 1.3 ¦ 13.7 ¦ 18.8 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> #> Age group {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 117,917 ¦ 14,097 ¦ 93,229 ¦ 149,142 ¦ 11.4 ¦ 1.3 ¦ 8.9 ¦ 14.2 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 64,856 ¦ 7,018 ¦ 52,387 ¦ 80,292 ¦ 6.3 ¦ 0.6 ¦ 5.1 ¦ 7.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-64 ¦ 479,777 ¦ 32,175 ¦ 420,624 ¦ 547,247 ¦ 46.3 ¦ 1.8 ¦ 42.7 ¦ 49.9 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65+ ¦ 373,935 ¦ 24,523 ¦ 328,777 ¦ 425,296 ¦ 36.1 ¦ 1.9 ¦ 32.3 ¦ 40   ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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":"(Nothing.)","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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 40 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int var_cross(\"Age x Sex\", \"AGER\", \"SEX\") tab(\"Age x Sex\") #> (Patient age recode) x (Patient sex) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 59,958 ¦ 7,206 ¦ 47,318 ¦ 75,974 ¦ 5.8 ¦ 0.7 ¦ 4.5 ¦ 7.3 ¦ #> ¦ years : ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> ¦ Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years : ¦ 41,128 ¦ 4,532 ¦ 33,066 ¦ 51,156 ¦ 4   ¦ 0.4 ¦ 3.2 ¦ 4.9 ¦ #> ¦ Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years : ¦ 113,708 ¦ 11,461 ¦ 93,256 ¦ 138,646 ¦ 11   ¦ 1   ¦ 9   ¦ 13.2 ¦ #> ¦ Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years : ¦ 175,978 ¦ 16,009 ¦ 147,153 ¦ 210,450 ¦ 17   ¦ 1.1 ¦ 14.8 ¦ 19.3 ¦ #> ¦ Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years : ¦ 120,099 ¦ 11,066 ¦ 100,171 ¦ 143,992 ¦ 11.6 ¦ 1   ¦ 9.7 ¦ 13.7 ¦ #> ¦ Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 94,173 ¦ 11,085 ¦ 74,682 ¦ 118,751 ¦ 9.1 ¦ 0.9 ¦ 7.3 ¦ 11.1 ¦ #> ¦ over : Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 57,959 ¦ 7,728 ¦ 44,570 ¦ 75,371 ¦ 5.6 ¦ 0.7 ¦ 4.3 ¦ 7.2 ¦ #> ¦ years : Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years : ¦ 23,728 ¦ 4,344 ¦ 16,457 ¦ 34,210 ¦ 2.3 ¦ 0.4 ¦ 1.6 ¦ 3.2 ¦ #> ¦ Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years : ¦ 56,562 ¦ 7,277 ¦ 43,861 ¦ 72,942 ¦ 5.5 ¦ 0.6 ¦ 4.3 ¦ 6.8 ¦ #> ¦ Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years : ¦ 133,528 ¦ 12,956 ¦ 110,319 ¦ 161,619 ¦ 12.9 ¦ 1   ¦ 10.9 ¦ 15.1 ¦ #> ¦ Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years : ¦ 86,766 ¦ 6,767 ¦ 74,409 ¦ 101,176 ¦ 8.4 ¦ 0.6 ¦ 7.2 ¦ 9.7 ¦ #> ¦ Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 72,896 ¦ 6,661 ¦ 60,872 ¦ 87,296 ¦ 7   ¦ 0.6 ¦ 5.9 ¦ 8.3 ¦ #> ¦ over : Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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":"(Nothing.)","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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 41 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int 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: Age group: overwriting a variable that already exists. tab(\"Age group\") #> Age group {NAMCS 2019 PUF} #> +-------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +-------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 1 ¦ 31,148 ¦ 5,282 ¦ 22,269 ¦ 43,566 ¦ 3   ¦ 0.5 ¦ 2.1 ¦ 4.1 ¦ #> +-------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 1-4 ¦ 38,240 ¦ 5,444 ¦ 28,864 ¦ 50,662 ¦ 3.7 ¦ 0.5 ¦ 2.7 ¦ 4.8 ¦ #> +-------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 5-14 ¦ 48,529 ¦ 5,741 ¦ 38,430 ¦ 61,282 ¦ 4.7 ¦ 0.5 ¦ 3.7 ¦ 5.9 ¦ #> +-------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-64 ¦ 544,632 ¦ 36,082 ¦ 478,254 ¦ 620,223 ¦ 52.5 ¦ 2   ¦ 48.6 ¦ 56.5 ¦ #> +-------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65 and over ¦ 373,935 ¦ 24,523 ¦ 328,777 ¦ 425,296 ¦ 36.1 ¦ 1.9 ¦ 32.3 ¦ 40   ¦ #> +-------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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, screen = getOption(\"surveytable.screen\"), 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? screen print screen? 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":"data.frame","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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 41 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int var_list(\"age\") #> Variables beginning with 'age' {NAMCS 2019 PUF} #> +----------------------------------------------------------------+ #> ¦ Variable ¦ Class ¦ Label ¦ #> +-----------+---------+------------------------------------------¦ #> ¦ AGE ¦ numeric ¦ Patient age in years (raw - use caution) ¦ #> +-----------+---------+------------------------------------------¦ #> ¦ AGER ¦ factor ¦ Patient age recode ¦ #> +-----------+---------+------------------------------------------¦ #> ¦ Age group ¦ factor ¦ Age group ¦ #> +-----------+---------+------------------------------------------¦ #> ¦ Age x Sex ¦ factor ¦ (Patient age recode) x (Patient sex) ¦ #> +----------------------------------------------------------------+ #>"}] +[{"path":"https://cdcgov.github.io/surveytable/articles/a01-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. Check survey name, survey design variables, number observations verify looks correct.","code":"library(surveytable) mysurvey = vars2019 # Or, if nchsdata has been installed, # mysurvey = nchsdata::namcs2019 set_survey(\"mysurvey\") ## _ ## Survey name NAMCS 2019 PUF ## Number of variables 36 ## Number of observations 8250 ## Stratified 1 - level Cluster Sampling design (with replacement) ## With (398) clusters. ## svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, ## data = d1) ## * To adjust how counts are rounded, see ?set_count_int"},{"path":[]},{"path":"https://cdcgov.github.io/surveytable/articles/a01-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/a01-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} Recall survey design objects element called variables, data frame contains survey variables. Let’s examine levels MSA. calculate rates particular variable, need provide data frame variable called Level matches levels variable survey. Population gives population estimate. example, MSA, 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) levels(mysurvey$variables$MSA) ## [1] \"MSA (Metropolitan Statistical Area)\" \"Non-MSA\" 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/a01-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/a01-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/a01-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 syntax. (survey imported R using importsurvey package, automatically detects binary variables imports logical variables.) Recall survey design objects element called variables, data frame contains survey variables. Notes: ’re using within() function simplify syntax. nopwu = payment used, private, Medicare, etc. Self-pay (real) = self-pay used payment used. 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 (real) {NAMCS 2019 PUF} charge (real) {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":"mysurvey$variables = within(mysurvey$variables, { `Medicare and Medicaid` = PAYMCARE & PAYMCAID `Unknown or blank` = PAYDK | (NOPAY == \"No categories marked\") nopwu = !( PAYPRIV | PAYMCARE | PAYMCAID | PAYWKCMP | PAYOTH | PAYDK) `Self-pay (real)` = PAYSELF & nopwu `No charge (real)` = PAYNOCHG & nopwu `No insurance` = `Self-pay (real)` | `No charge (real)` }) tab(\"PAYPRIV\", \"PAYMCARE\", \"PAYMCAID\", \"Medicare and Medicaid\" , \"No insurance\", \"Self-pay (real)\", \"No charge (real)\" , \"PAYWKCMP\", \"PAYOTH\", \"Unknown or blank\")"},{"path":"https://cdcgov.github.io/surveytable/articles/a01-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/a01-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. variable Age group already created previous example. 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} (Patient age recode) x (Patient 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} (Patient age recode) x (Patient sex) (Major reason visit = Preventive care) {NAMCS 2019 PUF}","code":"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\")) { tab_subset(vr, \"MAJOR\", \"Preventive care\") }"},{"path":"https://cdcgov.github.io/surveytable/articles/a01-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 many tables produced, output sent CSV file, printed screen. , 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 , screen output turned back . run code, tables stored CSV file. give idea tables look like, just one tables: Type specialty (Primary, Medical, Surgical) ((Major reason visit) x (Patient age recode) = Preventive care : 15 years) {NAMCS 2019 PUF} match percentage published table, see “Primary care specialty” row. sure check presentation standards flags.","code":"set_output(csv = \"out.csv\", screen = FALSE) for (vr in c(\"AGER\", \"Age group\", \"SEX\", \"Age x Sex\")) { var_cross(\"tmp\", \"MAJOR\", vr) for (lvl in levels(mysurvey$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 = \"\", screen = TRUE) ## * Turning off CSV output. ## * Sending output to the screen. ## * ?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(mysurvey$variables[,vr])[1] tab_subset(\"SPECCAT\", \"tmp\", paste0(\"Preventive care : \", lvl))"},{"path":"https://cdcgov.github.io/surveytable/articles/a02-Example-Residential-Care-Community-RCC-Services-User-SU.html","id":"begin","dir":"Articles","previous_headings":"","what":"Begin","title":"Example: Residential Care Community (RCC) Services User (SU)","text":"Begin loading surveytable package. , print message explaining specify survey ’d like analyze. omitting message . Now, specify survey ’d like analyze. Check survey name, survey design variables, number observations verify looks correct.","code":"library(surveytable) mysurvey = nchsdata::rccsu2018 set_survey(\"mysurvey\") #> _ #> Survey name RCC SU 2018 PUF #> Number of variables 81 #> Number of observations 904 #> Stratified Independent Sampling design #> svydesign(ids = ~1, strata = ~pufstrata2 + su_facid, fpc = ~pufpopfac2, #> weights = ~suwt, data = d1) #> * To adjust how counts are rounded, see ?set_count_int"},{"path":"https://cdcgov.github.io/surveytable/articles/a02-Example-Residential-Care-Community-RCC-Services-User-SU.html","id":"figure-1","dir":"Articles","previous_headings":"","what":"Figure 1","title":"Example: Residential Care Community (RCC) Services User (SU)","text":"figure shows percentage residents sex, race / ethnicity, age group. Let’s find race / ethnicity variable: 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. Now, let’s take look age variable: Variables beginning ‘age’ {RCC SU 2018 PUF} age2 numeric variable. need create categorical variable based numeric variable. done using var_cut function. now variables needed figure. Let’s tabulate : Resident’s gender {RCC SU 2018 PUF} Resident’s race/ethnicity {RCC SU 2018 PUF} Age {RCC SU 2018 PUF}","code":"var_list(\"race\") tab(\"raceeth2\") var_collapse(\"raceeth2\", \"Another race or ethnicity\", c(\"Hispanic\", \"Other\")) var_list(\"age\") var_cut(\"Age\", \"age2\" , c(-Inf, 64, 74, 84, Inf) , c(\"Under 65\", \"65-74\", \"75-84\", \"85 and over\") ) tab(\"sex\", \"raceeth2\", \"Age\")"},{"path":"https://cdcgov.github.io/surveytable/articles/a02-Example-Residential-Care-Community-RCC-Services-User-SU.html","id":"figure-2","dir":"Articles","previous_headings":"","what":"Figure 2","title":"Example: Residential Care Community (RCC) Services User (SU)","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 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/a02-Example-Residential-Care-Community-RCC-Services-User-SU.html","id":"figure-4","dir":"Articles","previous_headings":"","what":"Figure 4","title":"Example: Residential Care Community (RCC) Services User (SU)","text":"(Figure 3 slightly involved, ’ll next.) figure shows percentage residents one select set chronic conditions. addition, shows distribution residents number conditions. 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} Now, count many chronic conditions present. Recall survey design objects element called variables, data frame contains survey variables. generating figure, create categorical variable based num_cc, numeric. Number chronic conditions {RCC SU 2018 PUF}","code":"tab(\"hbp\") tab(\"hbp\", \"alz\", \"depress\", \"arth\", \"diabetes\", \"heartdise\", \"osteo\" , \"copd\", \"stroke\", \"cancer\" , drop_na = TRUE) mysurvey$variables$num_cc = 0 for (vr in c(\"hbp\", \"alz\", \"depress\", \"arth\", \"diabetes\", \"heartdise\", \"osteo\" , \"copd\", \"stroke\", \"cancer\")) { idx = which(mysurvey$variables[,vr]) mysurvey$variables$num_cc[idx] = mysurvey$variables$num_cc[idx] + 1 } 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/a02-Example-Residential-Care-Community-RCC-Services-User-SU.html","id":"figure-3","dir":"Articles","previous_headings":"","what":"Figure 3","title":"Example: Residential Care Community (RCC) Services User (SU)","text":"figure shows percentage residents need help one activities daily living (ADLs). addition, shows distribution residents number ADLs need help. presented figure, ADLs, resident either need help. words, figure, ’s binary variable. Let’s take look levels one ADLs variables, exists survey: Several levels correspond resident needing help, one level = need help, one level = unknown. Let’s convert ADLs variables logical variables (called tmp ) immediately tabulate logical variables. addition, let’s count many ADLs present: 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} generating figure, create categorical variable based num_adl, numeric. Number ADLs {RCC SU 2018 PUF}","code":"levels(mysurvey$variables$bathhlp) #> [1] \"MISSING\" #> [2] \"NEED HELP OR SUPERVISION FROM ANOTHER PERSON\" #> [3] \"USE OF AN ASSISTIVE DEVICE\" #> [4] \"BOTH\" #> [5] \"NEED NO ASSISTANCE\" vrs = c(\"bathhlp\", \"walkhlp\", \"dreshlp\", \"transhlp\", \"toilhlp\", \"eathlp\") mysurvey$variables$num_adl = 0 for (vr in vrs) { mysurvey$variables$tmp = NA mysurvey$variables$tmp[which(mysurvey$variables[,vr] %in% c(\"NEED HELP OR SUPERVISION FROM ANOTHER PERSON\" , \"USE OF AN ASSISTIVE DEVICE\" , \"BOTH\"))] = TRUE mysurvey$variables$tmp[which(mysurvey$variables[,vr] == \"NEED NO ASSISTANCE\")] = FALSE # If neither TRUE nor FALSE, stays as NA (unknown). # Transfer the variable label attr(mysurvey$variables$tmp, \"label\") = attr(mysurvey$variables[,vr], \"label\") # Percentages based on knowns only tab(\"tmp\", drop_na = TRUE) # Count idx = which(mysurvey$variables$tmp) mysurvey$variables$num_adl[idx] = mysurvey$variables$num_adl[idx] + 1 } var_cut(\"Number of ADLs\", \"num_adl\" , c(-Inf, 0, 2, 6, Inf) , c(\"0\", \"1-2\", \"3-6\", \"??\")) tab(\"Number of ADLs\")"},{"path":"https://cdcgov.github.io/surveytable/articles/a03-Example-National-Ambulatory-Medical-Care-Survey-NAMCS-report.html","id":"begin","dir":"Articles","previous_headings":"","what":"Begin","title":"Example: National Ambulatory Medical Care Survey (NAMCS) report","text":"Begin loading surveytable package. , print message explaining specify survey ’d like analyze. omitting message . Now, specify survey ’d like analyze. Check survey name, survey design variables, number observations verify looks correct.","code":"library(surveytable) mysurvey = nchsdata::namcs2019 set_survey(\"mysurvey\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 1100 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int"},{"path":"https://cdcgov.github.io/surveytable/articles/a03-Example-National-Ambulatory-Medical-Care-Survey-NAMCS-report.html","id":"figure-1-and-table-1","dir":"Articles","previous_headings":"","what":"Figure 1 and Table 1","title":"Example: National Ambulatory Medical Care Survey (NAMCS) report","text":"figure table show rate visits, overall, age group, sex. First, let’s convert numeric variable AGE categorical variable categories used figure. Converting numeric variable categorical variable done var_cut function. Given population estimates available uspop2019, calculate rates: Total (rate per 100 population) {NAMCS 2019 PUF} Age group 5 (rate per 100 population) {NAMCS 2019 PUF} Patient sex (rate per 100 population) {NAMCS 2019 PUF}","code":"var_cut(\"Age group 5\", \"AGE\" , c(-Inf, 0, 17, 44, 64, Inf) , c(\"Under 1\", \"1-17\", \"18-44\", \"45-64\", \"65 and over\")) total_rate(uspop2019$total) tab_rate(\"Age group 5\", uspop2019$`Age group 5`) tab_rate(\"SEX\", uspop2019$SEX)"},{"path":"https://cdcgov.github.io/surveytable/articles/a03-Example-National-Ambulatory-Medical-Care-Survey-NAMCS-report.html","id":"figure-2-and-table-2","dir":"Articles","previous_headings":"","what":"Figure 2 and Table 2","title":"Example: National Ambulatory Medical Care Survey (NAMCS) report","text":"figure shows distribution primary expected source payment, tests whether pairs percentages equal. table shows info age group. First, let’s examine levels PAYTYPER (Type payment). Recall survey design objects element called variables, data frame contains survey variables. published figure, “Self-pay” “charge/Charity” combined category called “insurance”. Additionally, categories shown published figure, combine category called “etc”. Let’s combine categories: Now, tabulate variable, testing equality levels: Type payment (recoded multiple sources using hierarchy) {NAMCS 2019 PUF} Comparison possible pairs Type payment (recoded multiple sources using hierarchy) {NAMCS 2019 PUF} can ignore results “etc” category, since ’s shown figure. Note presentation flags “insurance” category. second table indicates differences statistically significant. replicate table, need variable age categories – categories different ones created . Thus, create another age category variable, tabulate subsets: Type payment (recoded multiple sources using hierarchy) (Age group = 18) {NAMCS 2019 PUF} Type payment (recoded multiple sources using hierarchy) (Age group = 18-64) {NAMCS 2019 PUF} Type payment (recoded multiple sources using hierarchy) (Age group = 65 ) {NAMCS 2019 PUF} , note presentation flags. flags concerned counts – since published table show counts, relevant. However, 18-64 age group, “insurance” category flagged.","code":"levels(mysurvey$variables$PAYTYPER) #> [1] \"All sources of payment are blank\" #> [2] \"Unknown\" #> [3] \"Private insurance\" #> [4] \"Medicare\" #> [5] \"Medicaid, CHIP or other state-based program\" #> [6] \"Worker's compensation\" #> [7] \"Self-pay\" #> [8] \"No charge/Charity\" #> [9] \"Other\" var_collapse(\"PAYTYPER\", \"No insurance\" , c(\"Self-pay\", \"No charge/Charity\")) var_collapse(\"PAYTYPER\", \"etc\" , c(\"All sources of payment are blank\", \"Unknown\" , \"Worker's compensation\", \"Other\") ) tab(\"PAYTYPER\", test = TRUE) var_cut(\"Age group\", \"AGE\" , c(-Inf, 17, 64, Inf) , c(\"Under 18\", \"18-64\", \"65 and over\")) tab_subset(\"PAYTYPER\", \"Age group\")"},{"path":"https://cdcgov.github.io/surveytable/articles/a03-Example-National-Ambulatory-Medical-Care-Survey-NAMCS-report.html","id":"figure-3-and-table-3","dir":"Articles","previous_headings":"","what":"Figure 3 and Table 3","title":"Example: National Ambulatory Medical Care Survey (NAMCS) report","text":"figure shows major reason visit. data system variable called MAJOR (Major reason visit), exactly variable shown figure. Rather, variable shown figure constructed two variables: MAJOR INJURY (visit related injury/trauma, …). Specifically, visit injury visit (indicated INJURY), figure counts . Otherwise, injury visit, figure counts according value MAJOR. addition, figure collapses levels MAJOR. Let’s begin collapsing levels MAJOR, match figure: Create new variable, called Reason. Initialize NA. Copy values MAJOR Reason “Blank” – MAJOR “Blank”, Reason becomes NA. Since ’ll combining two factor variables, easy solution convert character , convert back factor later. Now, let’s incorporate INJURY variable. Order matters! first added MAJOR, INJURY. Since INJURY added second, trumps value MAJOR. want. Since figure based knowns , use drop_na argument ignore missing values (NA): Reason (knowns ) {NAMCS 2019 PUF} Comparison possible pairs Reason (knowns ) {NAMCS 2019 PUF} table shows information, age group: Reason (Age group = 18) (knowns ) {NAMCS 2019 PUF} Reason (Age group = 18-64) (knowns ) {NAMCS 2019 PUF} Reason (Age group = 65 ) (knowns ) {NAMCS 2019 PUF}","code":"levels(mysurvey$variables$MAJOR) #> [1] \"Blank\" #> [2] \"New problem (less than 3 mos. onset)\" #> [3] \"Chronic problem, routine\" #> [4] \"Chronic problem, flare-up\" #> [5] \"Pre-surgery\" #> [6] \"Post-surgery\" #> [7] \"Preventive care\" var_collapse(\"MAJOR\", \"Pre- and postsurgery\" , c(\"Pre-surgery\", \"Post-surgery\")) var_collapse(\"MAJOR\", \"Chronic\" , c(\"Chronic problem, routine\", \"Chronic problem, flare-up\")) idx = which( mysurvey$variables$MAJOR != \"Blank\" ) mysurvey$variables$Reason[idx] = as.character( mysurvey$variables$MAJOR[idx] ) levels(mysurvey$variables$INJURY) #> [1] \"Blank\" \"Unknown\" #> [3] \"No\" \"Yes\" #> [5] \"Questionable injury status\" idx = which(mysurvey$variables$INJURY == \"Yes\") mysurvey$variables$Reason[idx] = \"Injury\" mysurvey$variables$Reason = as.factor(mysurvey$variables$Reason) tab(\"Reason\", drop_na = TRUE, test = TRUE) tab_subset(\"Reason\", \"Age group\", drop_na = TRUE)"},{"path":"https://cdcgov.github.io/surveytable/articles/a03-Example-National-Ambulatory-Medical-Care-Survey-NAMCS-report.html","id":"figure-4-and-table-4","dir":"Articles","previous_headings":"","what":"Figure 4 and Table 4","title":"Example: National Ambulatory Medical Care Survey (NAMCS) report","text":"figure shows percentage visits selected services ordered provided (mutually exclusive). table shows information age. Laboratory tests. survey several binary variables indicating whether certain laboratory test ordered provided. variables TRUE, counts laboratory test visit. Variables beginning ‘bmp’ {NAMCS 2019 PUF} Variables beginning ‘cbc’ {NAMCS 2019 PUF} create variable TRUE variable list TRUE, use var_any function: Laboratory tests {NAMCS 2019 PUF} variables. Three variables figure follow logic. Let’s create tabulate now. Health education {NAMCS 2019 PUF} Imaging services {NAMCS 2019 PUF} Procedures {NAMCS 2019 PUF} Examinations screenings. Examinations screenings little bit involved. variables , TRUE number variables TRUE. However, also TRUE another situation. five DIAGx.unformatted variables contain diagnosis codes. : Variables beginning ‘diag’ {NAMCS 2019 PUF} diagnosis codes begins either “Z0” “Z1”, Examinations screenings also TRUE. begin, let’s create logical variables true diagnosis codes begin either “Z0” “Z1”: Now, can use var_any list variables original survey, plus variables just created: Examinations screenings {NAMCS 2019 PUF} Table. published table shows age. many tables created, let’s send CSV file instead screen:","code":"var_list(\"bmp\") var_list(\"cbc\") var_any(\"Laboratory tests\" , c(\"BMP\", \"CBC\", \"CHLAMYD\", \"CMP\", \"CREAT\", \"BLDCX\", \"TRTCX\" , \"URNCX\", \"OTHCX\", \"GLUCOSE\", \"GCT\", \"HGBA\", \"HEPTEST\" , \"HIVTEST\", \"HPVDNA\", \"CHOLEST\", \"HEPATIC\", \"PAP\" , \"PREGTEST\", \"PSA\", \"STREP\", \"THYROID\", \"URINE\", \"VITD\")) tab(\"Laboratory tests\") var_any(\"Health education\" , c(\"ETOHED\", \"ASTHMAED\", \"ASTHMAP\", \"DIAEDUC\", \"DIETNUTR\", \"EXERCISE\" ,\"FAMPLAN\", \"GENETIC\", \"GRWTHDEV\", \"INJPREV\", \"STDPREV\", \"STRESMGT\" , \"SUBSTED\", \"TOBACED\", \"WTREDUC\")) tab(\"Health education\") var_any(\"Imaging services\" , c(\"ANYIMAGE\", \"BONEDENS\", \"CATSCAN\", \"ECHOCARD\", \"OTHULTRA\", \"MAMMO\" , \"MRI\", \"XRAY\", \"OTHIMAGE\") ) tab(\"Imaging services\") var_any(\"Procedures\" , c(\"AUDIO\", \"BIOPSY\", \"CARDIAC\", \"COLON\", \"CRYO\", \"EKG\", \"EEG\", \"EMG\", \"EXCISION\", \"FETAL\", \"PEAK\", \"SIGMOID\", \"SPIRO\", \"TONO\", \"TBTEST\", \"EGD\")) tab(\"Procedures\") var_list(\"diag\") for (ii in 1:5) { vr = paste0(\"DIAG\", ii, \".unformatted\") newvr = paste0(\"Z_DIAG\", ii) mysurvey$variables[,newvr] = ( startsWith(mysurvey$variables[,vr], \"Z0\") | startsWith(mysurvey$variables[,vr], \"Z1\")) } var_any(\"Examinations and screenings\" # Variables from the original survey , c(\"ETOH\", \"BREAST\", \"DEPRESS\", \"DVS\", \"FOOT\", \"NEURO\" , \"PELVIC\", \"RECTAL\", \"RETINAL\", \"SKIN\", \"SUBST\" # Newly created variables , \"Z_DIAG1\", \"Z_DIAG2\", \"Z_DIAG3\", \"Z_DIAG4\", \"Z_DIAG5\")) tab(\"Examinations and screenings\") set_output(csv = \"out.csv\", screen = FALSE) for (vr in c(\"Laboratory tests\", \"Health education\", \"Imaging services\" , \"Procedures\", \"Examinations and screenings\")) { tab_subset(vr, \"Age group\") } set_output(csv = \"\", screen = TRUE) #> * Turning off CSV output. #> * Sending output to the screen. #> * ?set_output for other options."},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"begin","dir":"Articles","previous_headings":"","what":"Begin","title":"Introduction to surveytable","text":"Begin loading surveytable package. , print message explaining specify survey ’d like analyze. showing message . Now, specify survey ’d like analyze. Check survey label, survey design variables, number observations verify looks correct.","code":"library(surveytable) set_survey(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"list-variables","dir":"Articles","previous_headings":"Begin","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, categorical variable age groups, 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 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 (variable indicating whether charge physician visit): 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} Optionally, one levels subsetting variable can specified, tabulate subsets. title table reflects value subsetting variable (case, SEX). tab_subset command, table (, subset), percentages add 100%. Another way tabulate subsets using tab_cross function, crosses interacts two variables generates table using new variable. estimated counts produced tab_subset tab_cross , tab_cross, percentages across entire population add 100%. (Patient age recode) x (Patient sex) {NAMCS 2019 PUF}","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 tab_subset functions make easy perform design-based t-test using test argument.","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":"test whether levels AGER statistically similar different, type: Patient age recode {NAMCS 2019 PUF} Comparison possible pairs Patient age recode {NAMCS 2019 PUF} According , following pairs categories statistically similar: “25-44 years” “65-74 years”; “25-44 years” “75 years ”. pairs categories statistically different.","code":"tab(\"AGER\", test = TRUE)"},{"path":"https://cdcgov.github.io/surveytable/articles/surveytable.html","id":"categorical-variables-subset","dir":"Articles","previous_headings":"Perform statistical hypothesis testing","what":"Categorical variables (subset)","title":"Introduction to surveytable","text":"test whether levels AGER statistically similar different within subpopulations defined SEX variable, type: Patient age recode (Patient sex = Female) {NAMCS 2019 PUF} Comparison possible pairs Patient age recode (Patient sex = Female) {NAMCS 2019 PUF} Patient age recode (Patient sex = Male) {NAMCS 2019 PUF} Comparison possible pairs Patient age recode (Patient sex = Male) {NAMCS 2019 PUF} According , following pairs categories statistically similar: “25-44 years” “65-74 years”; “25-44 years” “75 years ”. “15 years” “25-44 years”; “15 years” “75 years ”; “25-44 years” “75 years ”; “65-74 years” “75 years ”.","code":"tab_subset(\"AGER\", \"SEX\", 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":"test whether numeric variable NUMMED varies categorical variable AGER, type: Number medications coded (different levels Patient age recode) {NAMCS 2019 PUF} Comparison Number medications coded across possible pairs Patient age recode {NAMCS 2019 PUF} According , NUMMED statistically similar “15 years” “15-24 years” AGER categories. statistically different pairs categories.","code":"tab_subset(\"NUMMED\", \"AGER\", 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 vars2019 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. 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} Suppose analyst interested preventive care visits. Instead tabulating levels MAJOR, type: 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, 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. 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. analyst might need something interacted variable, possibly subset later. create interacted variable, use var_cross command: Now, example, create table age / sex interaction preventive care visits: (Patient age recode) x (Patient sex) (Major reason visit = Preventive care) {NAMCS 2019 PUF} 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} variables data frame. Recall survey design objects element called variables, data frame contains survey variables. advanced users can create modify variables variables data frame directly.","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, 4, 14, 64, Inf) , c(\"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\") tab_subset(\"Age x Sex\", \"MAJOR\", \"Preventive care\") 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\") class(vars2019$variables) #> [1] \"data.frame\""},{"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 also argument called screen, TRUE default, determines whether output sent screen. many tables produced, user might choose turn screen printing, output CSV file. tabulation functions called within R Markdown notebook, produce HTML tables. makes easy incorporate output surveytable package directly documents, presentations, “shiny” web apps, output types. Finally, tabulation functions return tables produce, either data frame, list data frames. advanced analysts can use functionality integrate surveytable programming tasks.","code":"set_output(csv = \"out.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. https://cdcgov.github.io/surveytable, https://github.com/CDCgov/surveytable.","code":"@Manual{, title = {surveytable: Formatted Survey Estimates}, author = {Alex Strashny}, year = {2023}, note = {https://cdcgov.github.io/surveytable, https://github.com/CDCgov/surveytable}, }"},{"path":"https://cdcgov.github.io/surveytable/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Welcome!","title":"Welcome!","text":"Thank contributing CDC’s Open Source projects! questions doubts, don’t afraid send way. appreciate contributions, looking forward fostering open, transparent, collaborative environment. contributing, encourage also read LICENSE, README, code--conduct files, also found repository. inquiries questions answered content repository, feel free contact us.","code":""},{"path":"https://cdcgov.github.io/surveytable/CONTRIBUTING.html","id":"public-domain","dir":"","previous_headings":"","what":"Public Domain","title":"Welcome!","text":"project public domain within United States, copyright related rights work worldwide waived CC0 1.0 Universal public domain dedication. contributions project released CC0 dedication. submitting pull request agreeing comply waiver copyright interest.","code":""},{"path":"https://cdcgov.github.io/surveytable/CONTRIBUTING.html","id":"requesting-changes","dir":"","previous_headings":"","what":"Requesting Changes","title":"Welcome!","text":"pull request/merging process designed give CDC Surveillance Team space opportunity consider discuss suggested changes. policy affects CDC spaces, -line , users expected abide .","code":""},{"path":"https://cdcgov.github.io/surveytable/CONTRIBUTING.html","id":"open-an-issue-in-the-repository","dir":"","previous_headings":"Requesting Changes","what":"Open an issue in the repository","title":"Welcome!","text":"don’t specific language submit like suggest change something addressed, can open issue repository. Team members respond issue soon possible.","code":""},{"path":"https://cdcgov.github.io/surveytable/CONTRIBUTING.html","id":"submit-a-pull-request","dir":"","previous_headings":"Requesting Changes","what":"Submit a pull request","title":"Welcome!","text":"like contribute, please submit pull request. order us merge pull request, must: * least seven days old. Pull requests may held longer necessary give people opportunity assess . * Receive +1 majority team members associated request. significant dissent team, meeting held discuss plan action pull request.","code":""},{"path":"https://cdcgov.github.io/surveytable/DISCLAIMER.html","id":null,"dir":"","previous_headings":"","what":"DISCLAIMER","title":"DISCLAIMER","text":"Use service limited non-sensitive publicly available data. Users must use, share, store kind sensitive data like health status, provision payment healthcare, Personally Identifiable Information (PII) /Protected Health Information (PHI), etc. circumstance. Administrators service reserve right moderate information used, shared, stored service time. user abide disclaimer Code Conduct may subject action, including revoking access services. material embodied software provided “-” without warranty kind, express, implied otherwise, including without limitation, warranty fitness particular purpose. event shall Centers Disease Control Prevention (CDC) United States (U.S.) government liable anyone else direct, special, incidental, indirect consequential damages kind, damages whatsoever, including without limitation, loss profit, loss use, savings revenue, claims third parties, whether CDC U.S. government advised possibility loss, however caused theory liability, arising connection possession, use performance software.","code":""},{"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 package provides short understandable commands generate tabulated, formatted, rounded survey estimates. One useful function, operates categorical logical variables, tabulates estimated counts percentages standard errors confidence intervals. functions list variables survey, estimate total population, tabulate survey subsets variable interactions, tabulate numeric variables, tabulate rates, create modify survey variables, perform t-tests, save output. tabulation functions check NCHS presentation standards flag low-precision estimates. surveytable code called R Markdown notebook Quarto document, generates HTML tables, can incorporated directly documents.","code":""},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Formatted Survey Estimates","text":"can install surveytable like :","code":"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. Patient age recode {NAMCS 2019 PUF}","code":"library(surveytable) set_survey(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int tab(\"AGER\")"},{"path":"https://cdcgov.github.io/surveytable/index.html","id":"related-packages","dir":"","previous_headings":"","what":"Related packages","title":"Formatted Survey Estimates","text":", 3 related packages: surveytable: functions tabulating survey estimates nchsdata: public use files (PUFs) National Center Health Statistics (NCHS) importsurvey: functions importing data R importsurvey imports surveys R currently formats. Public versions surveys already imported stored nchsdata. Tables estimates can generated using surveytable.","code":""},{"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 http://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 http://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 http://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":"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":"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":"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":"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":"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":"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":"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":"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":"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/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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int set_count_int() #> * Rounding counts to the nearest integer. #> * ?set_count_int for other options. total() #> Total {NAMCS 2019 PUF} #> +----------------------------------------------------------+ #> ¦ Number ¦ SE ¦ LL ¦ UL ¦ #> +---------------+------------+-------------+---------------¦ #> ¦ 1,036,484,356 ¦ 48,836,217 ¦ 945,013,590 ¦ 1,136,808,860 ¦ #> +----------------------------------------------------------+ #> (Checked presentation standards. Nothing to #> report.) #> set_count_1k() #> * Rounding counts to the nearest 1,000. #> * ?set_count_1k for other options. total() #> Total {NAMCS 2019 PUF} #> +---------------------------------------------------------------+ #> ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ #> +---------------+---------------+---------------+---------------¦ #> ¦ 1,036,484 ¦ 48,836 ¦ 945,014 ¦ 1,136,809 ¦ #> +---------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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(csv = NULL, screen = NULL, max_levels = 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":"csv name CSV file \"\" turn CSV output screen print screen? max_levels categorical variable can many levels. Used avoid printing huge tables.","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":"if (FALSE) { set_output(csv = \"out.csv\") show_output() } 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":"need specify survey functions, tab(), work.","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(survey_name = \"\") show_survey()"},{"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":"survey_name name survey.design object (quotation marks)","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":"(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":"show_survey() shows survey specified. Optionally, survey can attribute called label, long name survey. attribute set importsurvey package, can also set manually. Optionally, variable survey can attribute called label, variable's long name. attribute set haven importsurvey packages, can also set manually.","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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int show_survey() #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int"},{"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":"Show package 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.check_present #> [1] TRUE #> #> $surveytable.csv #> [1] \"\" #> #> $surveytable.drop_na #> [1] FALSE #> #> $surveytable.max_levels #> [1] 20 #> #> $surveytable.names_count #> [1] \"Number (000)\" \"SE (000)\" \"LL (000)\" \"UL (000)\" #> #> $surveytable.names_prct #> [1] \"Percent\" \"SE\" \"LL\" \"UL\" #> #> $surveytable.present_count #> [1] \".present_count\" #> #> $surveytable.present_prop #> [1] \".present_prop\" #> #> $surveytable.present_restricted #> [1] \".present_restricted\" #> #> $surveytable.rate_per #> [1] 100 #> #> $surveytable.screen #> [1] TRUE #> #> $surveytable.survey #> [1] \"vars2019\" #> #> $surveytable.survey_label #> [1] \"NAMCS 2019 PUF\" #> #> $surveytable.tx_count #> [1] \".tx_count_1k\" #> #> $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.","code":""},{"path":[]},{"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":"Formatted Survey Estimates.","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","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 design object subset expression specifying subpopulation label survey label newly created survey design 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 design 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(vars2019, AGE < 18, \"Children\") set_survey(\"children\") #> Error: children does not exist. Did you forget to load it? tab(\"AGER\") #> Patient age recode {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 117,917 ¦ 14,097 ¦ 93,229 ¦ 149,142 ¦ 11.4 ¦ 1.3 ¦ 8.9 ¦ 14.2 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 64,856 ¦ 7,018 ¦ 52,387 ¦ 80,292 ¦ 6.3 ¦ 0.6 ¦ 5.1 ¦ 7.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 170,271 ¦ 13,966 ¦ 144,925 ¦ 200,049 ¦ 16.4 ¦ 1.1 ¦ 14.3 ¦ 18.8 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 309,506 ¦ 23,290 ¦ 266,994 ¦ 358,787 ¦ 29.9 ¦ 1.4 ¦ 27.2 ¦ 32.6 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 206,866 ¦ 14,366 ¦ 180,481 ¦ 237,109 ¦ 20   ¦ 1.2 ¦ 17.6 ¦ 22.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 167,069 ¦ 15,179 ¦ 139,746 ¦ 199,735 ¦ 16.1 ¦ 1.3 ¦ 13.7 ¦ 18.8 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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\"), 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. df_method: \"default\", df = degf(design); \"NHIS\", df = nrow(design) - 1.","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. use function tabulations, 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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int options(surveytable.adjust_svyciprop = TRUE) tab(\"AGER\") #> Patient age recode {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 117,917 ¦ 14,097 ¦ 93,229 ¦ 149,142 ¦ 11.4 ¦ 1.3 ¦ 8.9 ¦ 14.2 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 64,856 ¦ 7,018 ¦ 52,387 ¦ 80,292 ¦ 6.3 ¦ 0.6 ¦ 5.1 ¦ 7.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 170,271 ¦ 13,966 ¦ 144,925 ¦ 200,049 ¦ 16.4 ¦ 1.1 ¦ 14.3 ¦ 18.8 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 309,506 ¦ 23,290 ¦ 266,994 ¦ 358,787 ¦ 29.9 ¦ 1.4 ¦ 27.2 ¦ 32.6 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 206,866 ¦ 14,366 ¦ 180,481 ¦ 237,109 ¦ 20   ¦ 1.2 ¦ 17.6 ¦ 22.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 167,069 ¦ 15,179 ¦ 139,746 ¦ 199,735 ¦ 16.1 ¦ 1.3 ¦ 13.7 ¦ 18.8 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> options(surveytable.adjust_svyciprop = FALSE) tab(\"AGER\") #> Patient age recode {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 117,917 ¦ 14,097 ¦ 93,229 ¦ 149,142 ¦ 11.4 ¦ 1.3 ¦ 8.9 ¦ 14.2 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 64,856 ¦ 7,018 ¦ 52,387 ¦ 80,292 ¦ 6.3 ¦ 0.6 ¦ 5.1 ¦ 7.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 170,271 ¦ 13,966 ¦ 144,925 ¦ 200,049 ¦ 16.4 ¦ 1.1 ¦ 14.3 ¦ 18.8 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 309,506 ¦ 23,290 ¦ 266,994 ¦ 358,787 ¦ 29.9 ¦ 1.4 ¦ 27.2 ¦ 32.6 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 206,866 ¦ 14,366 ¦ 180,481 ¦ 237,109 ¦ 20   ¦ 1.2 ¦ 17.6 ¦ 22.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 167,069 ¦ 15,179 ¦ 139,746 ¦ 199,735 ¦ 16.1 ¦ 1.3 ¦ 13.7 ¦ 18.8 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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, drop_na = getOption(\"surveytable.drop_na\"), max_levels = getOption(\"surveytable.max_levels\"), screen = getOption(\"surveytable.screen\"), 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 test? alpha significance level test. drop_na drop missing values (NA)? Categorical variables . max_levels categorical variable can many levels. Used avoid printing huge tables. screen print screen? 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 data.frame tables single data.frame 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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int tab(\"AGER\") #> Patient age recode {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 117,917 ¦ 14,097 ¦ 93,229 ¦ 149,142 ¦ 11.4 ¦ 1.3 ¦ 8.9 ¦ 14.2 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 64,856 ¦ 7,018 ¦ 52,387 ¦ 80,292 ¦ 6.3 ¦ 0.6 ¦ 5.1 ¦ 7.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 170,271 ¦ 13,966 ¦ 144,925 ¦ 200,049 ¦ 16.4 ¦ 1.1 ¦ 14.3 ¦ 18.8 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 309,506 ¦ 23,290 ¦ 266,994 ¦ 358,787 ¦ 29.9 ¦ 1.4 ¦ 27.2 ¦ 32.6 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 206,866 ¦ 14,366 ¦ 180,481 ¦ 237,109 ¦ 20   ¦ 1.2 ¦ 17.6 ¦ 22.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 167,069 ¦ 15,179 ¦ 139,746 ¦ 199,735 ¦ 16.1 ¦ 1.3 ¦ 13.7 ¦ 18.8 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> tab(\"MDDO\", \"SPECCAT\", \"MSA\") #> Type of doctor (MD or DO) {NAMCS 2019 PUF} #> +----------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+-----------+---------+-----+------+------¦ #> ¦ M.D. - Doctor ¦ 980,280 ¦ 48,388 ¦ 889,842 ¦ 1,079,910 ¦ 94.6 ¦ 0.7 ¦ 93.1 ¦ 95.8 ¦ #> ¦ of Medicine ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+-----------+---------+-----+------+------¦ #> ¦ D.O. - Doctor ¦ 56,204 ¦ 6,602 ¦ 44,597 ¦ 70,832 ¦ 5.4 ¦ 0.7 ¦ 4.2 ¦ 6.9 ¦ #> ¦ of Osteopathy ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +----------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> #> Type of specialty (Primary, Medical, Surgical) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Primary care ¦ 521,466 ¦ 31,136 ¦ 463,840 ¦ 586,252 ¦ 50.3 ¦ 2.6 ¦ 45.1 ¦ 55.5 ¦ #> ¦ specialty ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Surgical care ¦ 214,832 ¦ 31,110 ¦ 161,661 ¦ 285,490 ¦ 20.7 ¦ 3   ¦ 15.1 ¦ 27.3 ¦ #> ¦ specialty ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Medical care ¦ 300,186 ¦ 43,497 ¦ 225,806 ¦ 399,067 ¦ 29   ¦ 3.6 ¦ 22.1 ¦ 36.6 ¦ #> ¦ specialty ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> #> Metropolitan Statistical Area Status of physician location {NAMCS 2019 PUF} #> +----------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+-----------+---------+-----+------+------¦ #> ¦ MSA ¦ 973,676 ¦ 50,515 ¦ 879,490 ¦ 1,077,947 ¦ 93.9 ¦ 1.7 ¦ 89.6 ¦ 96.8 ¦ #> ¦ (Metropolitan ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> ¦ Statistical ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> ¦ Area) ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+-----------+---------+-----+------+------¦ #> ¦ Non-MSA ¦ 62,809 ¦ 17,549 ¦ 36,249 ¦ 108,830 ¦ 6.1 ¦ 1.7 ¦ 3.2 ¦ 10.4 ¦ #> +----------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> # 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 ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 117,917 ¦ 14,097 ¦ 93,229 ¦ 149,142 ¦ 11.4 ¦ 1.3 ¦ 8.9 ¦ 14.2 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 64,856 ¦ 7,018 ¦ 52,387 ¦ 80,292 ¦ 6.3 ¦ 0.6 ¦ 5.1 ¦ 7.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 170,271 ¦ 13,966 ¦ 144,925 ¦ 200,049 ¦ 16.4 ¦ 1.1 ¦ 14.3 ¦ 18.8 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 309,506 ¦ 23,290 ¦ 266,994 ¦ 358,787 ¦ 29.9 ¦ 1.4 ¦ 27.2 ¦ 32.6 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 206,866 ¦ 14,366 ¦ 180,481 ¦ 237,109 ¦ 20   ¦ 1.2 ¦ 17.6 ¦ 22.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 167,069 ¦ 15,179 ¦ 139,746 ¦ 199,735 ¦ 16.1 ¦ 1.3 ¦ 13.7 ¦ 18.8 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> #> 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 ¦ * ¦ #> +-----------------------------------------------------+ #> *: p-value <= 0.05 #> # Integrate the output into other programming tasks my_table = tab(\"AGER\", screen = FALSE) my_table = within(my_table, {RSE = `SE (000)` / `Number (000)`})"},{"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\"), screen = getOption(\"surveytable.screen\"), 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. screen print screen? 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 data.frame tables single data.frame 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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int # 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 ¦ Rate ¦ SE ¦ LL ¦ UL ¦ #> +----------------------------+-------+------+-------+-------¦ #> ¦ MSA (Metropolitan ¦ 351.2 ¦ 18.2 ¦ 317.2 ¦ 388.8 ¦ #> ¦ Statistical Area) ¦ ¦ ¦ ¦ ¦ #> +----------------------------+-------+------+-------+-------¦ #> ¦ Non-MSA ¦ 136.7 ¦ 38.2 ¦ 78.9 ¦ 236.8 ¦ #> +-----------------------------------------------------------+ #> (Checked presentation standards. Nothing to #> report.) #> # 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 ¦ Rate ¦ SE ¦ LL ¦ UL ¦ #> +----------------------------+-------+----+-------+-------¦ #> ¦ M.D. - Doctor of Medicine ¦ 303.3 ¦ 15 ¦ 275.3 ¦ 334.1 ¦ #> +----------------------------+-------+----+-------+-------¦ #> ¦ D.O. - Doctor of ¦ 17.4 ¦ 2 ¦ 13.8 ¦ 21.9 ¦ #> ¦ Osteopathy ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------+ #> (Checked presentation standards. Nothing to #> report.) #>"},{"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. Test equality proportions means.","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\"), screen = getOption(\"surveytable.screen\"), csv = getOption(\"surveytable.csv\") ) tab_subset( vr, vrby, lvls = c(), test = FALSE, alpha = 0.05, drop_na = getOption(\"surveytable.drop_na\"), max_levels = getOption(\"surveytable.max_levels\"), screen = getOption(\"surveytable.screen\"), 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. screen print screen? csv name CSV file lvls (optional) show levels vrby test perform hypothesis test? alpha significance level test. 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":"tab_subset: list data.frame tables single data.frame table. tab_cross: data.frame 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().","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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int # For each SEX, tabulate AGER tab_subset(\"AGER\", \"SEX\") #> Patient age recode (Patient sex = Female) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 59,958 ¦ 7,206 ¦ 47,318 ¦ 75,974 ¦ 9.9 ¦ 1.2 ¦ 7.6 ¦ 12.6 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 41,128 ¦ 4,532 ¦ 33,066 ¦ 51,156 ¦ 6.8 ¦ 0.7 ¦ 5.4 ¦ 8.4 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 113,708 ¦ 11,461 ¦ 93,256 ¦ 138,646 ¦ 18.8 ¦ 1.6 ¦ 15.8 ¦ 22.1 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 175,978 ¦ 16,009 ¦ 147,153 ¦ 210,450 ¦ 29.1 ¦ 1.7 ¦ 25.7 ¦ 32.6 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 120,099 ¦ 11,066 ¦ 100,171 ¦ 143,992 ¦ 19.8 ¦ 1.5 ¦ 17   ¦ 22.9 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 94,173 ¦ 11,085 ¦ 74,682 ¦ 118,751 ¦ 15.6 ¦ 1.5 ¦ 12.8 ¦ 18.7 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> #> Patient age recode (Patient sex = Male) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 57,959 ¦ 7,728 ¦ 44,570 ¦ 75,371 ¦ 13.4 ¦ 1.7 ¦ 10.3 ¦ 17.1 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 23,728 ¦ 4,344 ¦ 16,457 ¦ 34,210 ¦ 5.5 ¦ 0.8 ¦ 4   ¦ 7.4 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 56,562 ¦ 7,277 ¦ 43,861 ¦ 72,942 ¦ 13.1 ¦ 1.3 ¦ 10.7 ¦ 15.8 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 133,528 ¦ 12,956 ¦ 110,319 ¦ 161,619 ¦ 30.9 ¦ 1.6 ¦ 27.8 ¦ 34.3 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 86,766 ¦ 6,767 ¦ 74,409 ¦ 101,176 ¦ 20.1 ¦ 1.5 ¦ 17.3 ¦ 23.1 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 72,896 ¦ 6,661 ¦ 60,872 ¦ 87,296 ¦ 16.9 ¦ 1.5 ¦ 14   ¦ 20.2 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> # Same counts as tab_subset(), but different percentages. tab_cross(\"AGER\", \"SEX\") #> (Patient age recode) x (Patient sex) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 59,958 ¦ 7,206 ¦ 47,318 ¦ 75,974 ¦ 5.8 ¦ 0.7 ¦ 4.5 ¦ 7.3 ¦ #> ¦ years : ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> ¦ Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years : ¦ 41,128 ¦ 4,532 ¦ 33,066 ¦ 51,156 ¦ 4   ¦ 0.4 ¦ 3.2 ¦ 4.9 ¦ #> ¦ Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years : ¦ 113,708 ¦ 11,461 ¦ 93,256 ¦ 138,646 ¦ 11   ¦ 1   ¦ 9   ¦ 13.2 ¦ #> ¦ Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years : ¦ 175,978 ¦ 16,009 ¦ 147,153 ¦ 210,450 ¦ 17   ¦ 1.1 ¦ 14.8 ¦ 19.3 ¦ #> ¦ Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years : ¦ 120,099 ¦ 11,066 ¦ 100,171 ¦ 143,992 ¦ 11.6 ¦ 1   ¦ 9.7 ¦ 13.7 ¦ #> ¦ Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 94,173 ¦ 11,085 ¦ 74,682 ¦ 118,751 ¦ 9.1 ¦ 0.9 ¦ 7.3 ¦ 11.1 ¦ #> ¦ over : Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 57,959 ¦ 7,728 ¦ 44,570 ¦ 75,371 ¦ 5.6 ¦ 0.7 ¦ 4.3 ¦ 7.2 ¦ #> ¦ years : Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years : ¦ 23,728 ¦ 4,344 ¦ 16,457 ¦ 34,210 ¦ 2.3 ¦ 0.4 ¦ 1.6 ¦ 3.2 ¦ #> ¦ Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years : ¦ 56,562 ¦ 7,277 ¦ 43,861 ¦ 72,942 ¦ 5.5 ¦ 0.6 ¦ 4.3 ¦ 6.8 ¦ #> ¦ Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years : ¦ 133,528 ¦ 12,956 ¦ 110,319 ¦ 161,619 ¦ 12.9 ¦ 1   ¦ 10.9 ¦ 15.1 ¦ #> ¦ Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years : ¦ 86,766 ¦ 6,767 ¦ 74,409 ¦ 101,176 ¦ 8.4 ¦ 0.6 ¦ 7.2 ¦ 9.7 ¦ #> ¦ Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 72,896 ¦ 6,661 ¦ 60,872 ¦ 87,296 ¦ 7   ¦ 0.6 ¦ 5.9 ¦ 8.3 ¦ #> ¦ over : Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> # What are the levels or MAJOR? tab(\"MAJOR\") #> Major reason for this visit {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Blank ¦ 15,887 ¦ 3,354 ¦ 10,335 ¦ 24,419 ¦ 1.5 ¦ 0.3 ¦ 1   ¦ 2.3 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ New problem ¦ 275,014 ¦ 19,691 ¦ 238,955 ¦ 316,514 ¦ 26.5 ¦ 1.5 ¦ 23.7 ¦ 29.5 ¦ #> ¦ (less than 3 ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> ¦ mos. onset) ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Chronic ¦ 380,910 ¦ 35,080 ¦ 317,916 ¦ 456,386 ¦ 36.8 ¦ 2.5 ¦ 31.8 ¦ 41.9 ¦ #> ¦ problem, ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> ¦ routine ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Chronic ¦ 74,017 ¦ 9,329 ¦ 57,706 ¦ 94,939 ¦ 7.1 ¦ 0.9 ¦ 5.5 ¦ 9.1 ¦ #> ¦ problem, ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> ¦ flare-up ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Pre-surgery ¦ 12,864 ¦ 2,151 ¦ 9,188 ¦ 18,010 ¦ 1.2 ¦ 0.2 ¦ 0.9 ¦ 1.7 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Post-surgery ¦ 54,170 ¦ 6,749 ¦ 42,350 ¦ 69,289 ¦ 5.2 ¦ 0.7 ¦ 4   ¦ 6.7 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Preventive ¦ 223,624 ¦ 18,520 ¦ 190,068 ¦ 263,103 ¦ 21.6 ¦ 1.7 ¦ 18.3 ¦ 25.1 ¦ #> ¦ care ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> # Tabulate AGER by only 2 of the levels of MAJOR tab_subset(\"AGER\", \"MAJOR\" , lvls = c(\"Chronic problem, routine\", \"Chronic problem, flare-up\")) #> Patient age recode (Major reason for this visit = Chronic problem, routine) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 10,161 ¦ 1,941 ¦ 6,898 ¦ 14,966 ¦ 2.7 ¦ 0.5 ¦ 1.7 ¦ 4   ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 12,648 ¦ 2,365 ¦ 8,632 ¦ 18,534 ¦ 3.3 ¦ 0.7 ¦ 2.1 ¦ 4.9 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 48,324 ¦ 8,017 ¦ 34,763 ¦ 67,175 ¦ 12.7 ¦ 1.7 ¦ 9.5 ¦ 16.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 125,018 ¦ 14,947 ¦ 98,780 ¦ 158,225 ¦ 32.8 ¦ 2.1 ¦ 28.6 ¦ 37.2 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 92,148 ¦ 11,411 ¦ 72,189 ¦ 117,625 ¦ 24.2 ¦ 1.9 ¦ 20.5 ¦ 28.2 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 92,612 ¦ 12,722 ¦ 70,637 ¦ 121,422 ¦ 24.3 ¦ 2.5 ¦ 19.6 ¦ 29.6 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> #> Patient age recode (Major reason for this visit = Chronic problem, flare-up) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ Flags ¦ #> ¦ ¦ (000) ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +-------------+-------------+----------+----------+----------+---------+-----+------+------+--------¦ #> ¦ Under 15 ¦ 3,242 ¦ 1,303 ¦ 1,207 ¦ 8,706 ¦ 4.4 ¦ 1.8 ¦ 1.6 ¦ 9.4 ¦ Cx Px ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +-------------+-------------+----------+----------+----------+---------+-----+------+------+--------¦ #> ¦ 15-24 years ¦ 2,653 ¦ 713 ¦ 1,497 ¦ 4,705 ¦ 3.6 ¦ 1   ¦ 1.9 ¦ 6.1 ¦ ¦ #> +-------------+-------------+----------+----------+----------+---------+-----+------+------+--------¦ #> ¦ 25-44 years ¦ 10,733 ¦ 2,199 ¦ 7,022 ¦ 16,405 ¦ 14.5 ¦ 2.9 ¦ 9.1 ¦ 21.4 ¦ ¦ #> +-------------+-------------+----------+----------+----------+---------+-----+------+------+--------¦ #> ¦ 45-64 years ¦ 26,435 ¦ 4,930 ¦ 18,194 ¦ 38,408 ¦ 35.7 ¦ 4.3 ¦ 27.3 ¦ 44.9 ¦ ¦ #> +-------------+-------------+----------+----------+----------+---------+-----+------+------+--------¦ #> ¦ 65-74 years ¦ 19,642 ¦ 4,285 ¦ 12,605 ¦ 30,608 ¦ 26.5 ¦ 4.4 ¦ 18.1 ¦ 36.4 ¦ ¦ #> +-------------+-------------+----------+----------+----------+---------+-----+------+------+--------¦ #> ¦ 75 years ¦ 11,312 ¦ 2,615 ¦ 7,048 ¦ 18,156 ¦ 15.3 ¦ 2.7 ¦ 10.3 ¦ 21.5 ¦ ¦ #> ¦ and over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------------+ #> Cx: suppress count (and rate); Px: suppress percent #> # 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 with categorical variables tab_subset(\"AGER\", \"SEX\", test = TRUE) #> Patient age recode (Patient sex = Female) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 59,958 ¦ 7,206 ¦ 47,318 ¦ 75,974 ¦ 9.9 ¦ 1.2 ¦ 7.6 ¦ 12.6 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 41,128 ¦ 4,532 ¦ 33,066 ¦ 51,156 ¦ 6.8 ¦ 0.7 ¦ 5.4 ¦ 8.4 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 113,708 ¦ 11,461 ¦ 93,256 ¦ 138,646 ¦ 18.8 ¦ 1.6 ¦ 15.8 ¦ 22.1 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 175,978 ¦ 16,009 ¦ 147,153 ¦ 210,450 ¦ 29.1 ¦ 1.7 ¦ 25.7 ¦ 32.6 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 120,099 ¦ 11,066 ¦ 100,171 ¦ 143,992 ¦ 19.8 ¦ 1.5 ¦ 17   ¦ 22.9 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 94,173 ¦ 11,085 ¦ 74,682 ¦ 118,751 ¦ 15.6 ¦ 1.5 ¦ 12.8 ¦ 18.7 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> #> Comparison of all possible pairs of Patient age recode (Patient sex = Female) {NAMCS 2019 PUF} #> +-----------------------------------------------------+ #> ¦ Level 1 ¦ Level 2 ¦ p-value ¦ Flag ¦ #> +----------------+-------------------+---------+------¦ #> ¦ Under 15 years ¦ 15-24 years ¦ 0.01  ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ Under 15 years ¦ 25-44 years ¦ 0     ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ Under 15 years ¦ 45-64 years ¦ 0     ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ Under 15 years ¦ 65-74 years ¦ 0     ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ Under 15 years ¦ 75 years and over ¦ 0.007 ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ 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.677 ¦ ¦ #> +----------------+-------------------+---------+------¦ #> ¦ 25-44 years ¦ 75 years and over ¦ 0.201 ¦ ¦ #> +----------------+-------------------+---------+------¦ #> ¦ 45-64 years ¦ 65-74 years ¦ 0     ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ 45-64 years ¦ 75 years and over ¦ 0     ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ 65-74 years ¦ 75 years and over ¦ 0.034 ¦ * ¦ #> +-----------------------------------------------------+ #> *: p-value <= 0.05 #> #> Patient age recode (Patient sex = Male) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 57,959 ¦ 7,728 ¦ 44,570 ¦ 75,371 ¦ 13.4 ¦ 1.7 ¦ 10.3 ¦ 17.1 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 23,728 ¦ 4,344 ¦ 16,457 ¦ 34,210 ¦ 5.5 ¦ 0.8 ¦ 4   ¦ 7.4 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 56,562 ¦ 7,277 ¦ 43,861 ¦ 72,942 ¦ 13.1 ¦ 1.3 ¦ 10.7 ¦ 15.8 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 133,528 ¦ 12,956 ¦ 110,319 ¦ 161,619 ¦ 30.9 ¦ 1.6 ¦ 27.8 ¦ 34.3 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 86,766 ¦ 6,767 ¦ 74,409 ¦ 101,176 ¦ 20.1 ¦ 1.5 ¦ 17.3 ¦ 23.1 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 72,896 ¦ 6,661 ¦ 60,872 ¦ 87,296 ¦ 16.9 ¦ 1.5 ¦ 14   ¦ 20.2 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> #> Comparison of all possible pairs of Patient age recode (Patient sex = Male) {NAMCS 2019 PUF} #> +-----------------------------------------------------+ #> ¦ Level 1 ¦ Level 2 ¦ p-value ¦ Flag ¦ #> +----------------+-------------------+---------+------¦ #> ¦ Under 15 years ¦ 15-24 years ¦ 0     ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ Under 15 years ¦ 25-44 years ¦ 0.894 ¦ ¦ #> +----------------+-------------------+---------+------¦ #> ¦ Under 15 years ¦ 45-64 years ¦ 0     ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ Under 15 years ¦ 65-74 years ¦ 0.008 ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ Under 15 years ¦ 75 years and over ¦ 0.166 ¦ ¦ #> +----------------+-------------------+---------+------¦ #> ¦ 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.001 ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ 25-44 years ¦ 75 years and over ¦ 0.113 ¦ ¦ #> +----------------+-------------------+---------+------¦ #> ¦ 45-64 years ¦ 65-74 years ¦ 0     ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ 45-64 years ¦ 75 years and over ¦ 0     ¦ * ¦ #> +----------------+-------------------+---------+------¦ #> ¦ 65-74 years ¦ 75 years and over ¦ 0.105 ¦ ¦ #> +-----------------------------------------------------+ #> *: p-value <= 0.05 #> # Hypothesis testing with numeric variables 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 ¦ #> +---------------------------------------------------+ #> #> 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 ¦ * ¦ #> +-----------------------------------------------------+ #> *: p-value <= 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\"), screen = getOption(\"surveytable.screen\"), 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. screen print screen? 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 data.frame tables single data.frame 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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int tab_subset_rate(\"AGER\", \"SEX\", uspop2019$`AGER x SEX`) #> Patient age recode (Patient sex = Female) (rate per 100 population) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------+ #> ¦ Level ¦ Rate ¦ SE ¦ LL ¦ UL ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ Under 15 years ¦ 202.5 ¦ 24.3 ¦ 159.8 ¦ 256.6 ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ 15-24 years ¦ 198.4 ¦ 21.9 ¦ 159.5 ¦ 246.8 ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ 25-44 years ¦ 263.3 ¦ 26.5 ¦ 215.9 ¦ 321   ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ 45-64 years ¦ 414   ¦ 37.7 ¦ 346.2 ¦ 495.1 ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ 65-74 years ¦ 720.3 ¦ 66.4 ¦ 600.8 ¦ 863.6 ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ 75 years and over ¦ 758.1 ¦ 89.2 ¦ 601.2 ¦ 956   ¦ #> +---------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> #> Patient age recode (Patient sex = Male) (rate per 100 population) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------+ #> ¦ Level ¦ Rate ¦ SE ¦ LL ¦ UL ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ Under 15 years ¦ 187.4 ¦ 25   ¦ 144.1 ¦ 243.7 ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ 15-24 years ¦ 113.1 ¦ 20.7 ¦ 78.4 ¦ 163   ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ 25-44 years ¦ 133.4 ¦ 17.2 ¦ 103.4 ¦ 172   ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ 45-64 years ¦ 333.4 ¦ 32.3 ¦ 275.4 ¦ 403.5 ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ 65-74 years ¦ 594.8 ¦ 46.4 ¦ 510.1 ¦ 693.6 ¦ #> +-------------------+-------------+-------------+-------------+-------------¦ #> ¦ 75 years and over ¦ 801.2 ¦ 73.2 ¦ 669.1 ¦ 959.5 ¦ #> +---------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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( screen = getOption(\"surveytable.screen\"), 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":"screen print screen? 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":"data.frame","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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int total() #> Total {NAMCS 2019 PUF} #> +---------------------------------------------------------------+ #> ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ #> +---------------+---------------+---------------+---------------¦ #> ¦ 1,036,484 ¦ 48,836 ¦ 945,014 ¦ 1,136,809 ¦ #> +---------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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\"), screen = getOption(\"surveytable.screen\"), 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 screen print screen? 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":"data.frame","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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int total_rate(uspop2019$total) #> Total (rate per 100 population) {NAMCS 2019 PUF} #> +---------------------------------------------------------------+ #> ¦ Rate ¦ SE ¦ LL ¦ UL ¦ #> +---------------+---------------+---------------+---------------¦ #> ¦ 320.7 ¦ 15.1 ¦ 292.4 ¦ 351.7 ¦ #> +---------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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 noninstitutional 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/vars2019.html","id":null,"dir":"Reference","previous_headings":"","what":"Selected variables from the National Ambulatory Medical Care Survey (NAMCS) 2019 Public Use File (PUF) — vars2019","title":"Selected variables from the National Ambulatory Medical Care Survey (NAMCS) 2019 Public Use File (PUF) — vars2019","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/vars2019.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) — vars2019","text":"","code":"vars2019"},{"path":"https://cdcgov.github.io/surveytable/reference/vars2019.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) — vars2019","text":"object class survey.design2 (inherits survey.design) 8250 rows 36 columns.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/vars2019.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) — vars2019","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/vars2019.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) — vars2019","text":"survey design object 8,250 observations.","code":""},{"path":"https://cdcgov.github.io/surveytable/reference/var_any.html","id":null,"dir":"Reference","previous_headings":"","what":"Is any variable true? — var_any","title":"Is any variable true? — 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? — 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? — 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? — var_any","text":"(Nothing.)","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? — var_any","text":"","code":"set_survey(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 36 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int var_any(\"Imaging services\" , c(\"ANYIMAGE\", \"BONEDENS\", \"CATSCAN\", \"ECHOCARD\", \"OTHULTRA\" , \"MAMMO\", \"MRI\", \"XRAY\", \"OTHIMAGE\")) tab(\"Imaging services\") #> Imaging services {NAMCS 2019 PUF} #> +-------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +-------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ FALSE ¦ 901,115 ¦ 43,298 ¦ 820,085 ¦ 990,151 ¦ 86.9 ¦ 1.1 ¦ 84.6 ¦ 89.1 ¦ #> +-------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ TRUE ¦ 135,369 ¦ 13,574 ¦ 111,134 ¦ 164,890 ¦ 13.1 ¦ 1.1 ¦ 10.9 ¦ 15.4 ¦ #> +-------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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)"},{"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.","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":"(Nothing.)","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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 37 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int var_case(\"Preventive care visits\", \"MAJOR\", \"Preventive care\") tab(\"Preventive care visits\") #> Preventive care visits {NAMCS 2019 PUF} #> +-------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +-------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ FALSE ¦ 812,861 ¦ 45,220 ¦ 728,841 ¦ 906,566 ¦ 78.4 ¦ 1.7 ¦ 74.9 ¦ 81.7 ¦ #> +-------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ TRUE ¦ 223,624 ¦ 18,520 ¦ 190,068 ¦ 263,103 ¦ 21.6 ¦ 1.7 ¦ 18.3 ¦ 25.1 ¦ #> +-------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> var_case(\"Surgery-related visits\" , \"MAJOR\" , c(\"Pre-surgery\", \"Post-surgery\")) tab(\"Surgery-related visits\") #> Surgery-related visits {NAMCS 2019 PUF} #> +--------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +-------+--------------+----------+----------+-----------+---------+-----+------+------¦ #> ¦ FALSE ¦ 969,451 ¦ 47,976 ¦ 879,793 ¦ 1,068,246 ¦ 93.5 ¦ 0.8 ¦ 91.9 ¦ 94.9 ¦ #> +-------+--------------+----------+----------+-----------+---------+-----+------+------¦ #> ¦ TRUE ¦ 67,034 ¦ 7,810 ¦ 53,273 ¦ 84,348 ¦ 6.5 ¦ 0.8 ¦ 5.1 ¦ 8.1 ¦ #> +--------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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":"(Nothing.)","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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 39 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int tab(\"PRIMCARE\") #> Are you the patient's primary care provider? {NAMCS 2019 PUF} #> +----------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ Flags ¦ #> ¦ ¦ (000) ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------+-------------+----------+----------+----------+---------+-----+------+------+-------¦ #> ¦ Blank ¦ 1,150 ¦ 478 ¦ 440 ¦ 3,005 ¦ 0.1 ¦ 0   ¦ 0   ¦ 0.2 ¦ Cx ¦ #> +---------+-------------+----------+----------+----------+---------+-----+------+------+-------¦ #> ¦ Unknown ¦ 39,519 ¦ 9,507 ¦ 24,520 ¦ 63,692 ¦ 3.8 ¦ 0.9 ¦ 2.3 ¦ 6   ¦ ¦ #> +---------+-------------+----------+----------+----------+---------+-----+------+------+-------¦ #> ¦ Yes ¦ 383,481 ¦ 28,555 ¦ 331,362 ¦ 443,798 ¦ 37   ¦ 2.6 ¦ 31.9 ¦ 42.3 ¦ ¦ #> +---------+-------------+----------+----------+----------+---------+-----+------+------+-------¦ #> ¦ No ¦ 612,335 ¦ 43,282 ¦ 533,050 ¦ 703,413 ¦ 59.1 ¦ 2.5 ¦ 53.9 ¦ 64.1 ¦ ¦ #> +----------------------------------------------------------------------------------------------+ #> Cx: suppress count (and rate) #> var_collapse(\"PRIMCARE\", \"Unknown if PCP\", c(\"Blank\", \"Unknown\")) tab(\"PRIMCARE\") #> Are you the patient's primary care provider? {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Unknown if ¦ 40,669 ¦ 9,479 ¦ 25,619 ¦ 64,560 ¦ 3.9 ¦ 0.9 ¦ 2.4 ¦ 6.1 ¦ #> ¦ PCP ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Yes ¦ 383,481 ¦ 28,555 ¦ 331,362 ¦ 443,798 ¦ 37   ¦ 2.6 ¦ 31.9 ¦ 42.3 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ No ¦ 612,335 ¦ 43,282 ¦ 533,050 ¦ 703,413 ¦ 59.1 ¦ 2.5 ¦ 53.9 ¦ 64.1 ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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":"(Nothing.)","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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 39 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int 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 ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 117,917 ¦ 14,097 ¦ 93,229 ¦ 149,142 ¦ 11.4 ¦ 1.3 ¦ 8.9 ¦ 14.2 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 64,856 ¦ 7,018 ¦ 52,387 ¦ 80,292 ¦ 6.3 ¦ 0.6 ¦ 5.1 ¦ 7.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years ¦ 170,271 ¦ 13,966 ¦ 144,925 ¦ 200,049 ¦ 16.4 ¦ 1.1 ¦ 14.3 ¦ 18.8 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years ¦ 309,506 ¦ 23,290 ¦ 266,994 ¦ 358,787 ¦ 29.9 ¦ 1.4 ¦ 27.2 ¦ 32.6 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years ¦ 206,866 ¦ 14,366 ¦ 180,481 ¦ 237,109 ¦ 20   ¦ 1.2 ¦ 17.6 ¦ 22.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 167,069 ¦ 15,179 ¦ 139,746 ¦ 199,735 ¦ 16.1 ¦ 1.3 ¦ 13.7 ¦ 18.8 ¦ #> ¦ over ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #> #> Age group {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 117,917 ¦ 14,097 ¦ 93,229 ¦ 149,142 ¦ 11.4 ¦ 1.3 ¦ 8.9 ¦ 14.2 ¦ #> ¦ years ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years ¦ 64,856 ¦ 7,018 ¦ 52,387 ¦ 80,292 ¦ 6.3 ¦ 0.6 ¦ 5.1 ¦ 7.5 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-64 ¦ 479,777 ¦ 32,175 ¦ 420,624 ¦ 547,247 ¦ 46.3 ¦ 1.8 ¦ 42.7 ¦ 49.9 ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65+ ¦ 373,935 ¦ 24,523 ¦ 328,777 ¦ 425,296 ¦ 36.1 ¦ 1.9 ¦ 32.3 ¦ 40   ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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":"(Nothing.)","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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 40 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int var_cross(\"Age x Sex\", \"AGER\", \"SEX\") tab(\"Age x Sex\") #> (Patient age recode) x (Patient sex) {NAMCS 2019 PUF} #> +---------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 59,958 ¦ 7,206 ¦ 47,318 ¦ 75,974 ¦ 5.8 ¦ 0.7 ¦ 4.5 ¦ 7.3 ¦ #> ¦ years : ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> ¦ Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years : ¦ 41,128 ¦ 4,532 ¦ 33,066 ¦ 51,156 ¦ 4   ¦ 0.4 ¦ 3.2 ¦ 4.9 ¦ #> ¦ Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years : ¦ 113,708 ¦ 11,461 ¦ 93,256 ¦ 138,646 ¦ 11   ¦ 1   ¦ 9   ¦ 13.2 ¦ #> ¦ Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years : ¦ 175,978 ¦ 16,009 ¦ 147,153 ¦ 210,450 ¦ 17   ¦ 1.1 ¦ 14.8 ¦ 19.3 ¦ #> ¦ Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years : ¦ 120,099 ¦ 11,066 ¦ 100,171 ¦ 143,992 ¦ 11.6 ¦ 1   ¦ 9.7 ¦ 13.7 ¦ #> ¦ Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 94,173 ¦ 11,085 ¦ 74,682 ¦ 118,751 ¦ 9.1 ¦ 0.9 ¦ 7.3 ¦ 11.1 ¦ #> ¦ over : Female ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 15 ¦ 57,959 ¦ 7,728 ¦ 44,570 ¦ 75,371 ¦ 5.6 ¦ 0.7 ¦ 4.3 ¦ 7.2 ¦ #> ¦ years : Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-24 years : ¦ 23,728 ¦ 4,344 ¦ 16,457 ¦ 34,210 ¦ 2.3 ¦ 0.4 ¦ 1.6 ¦ 3.2 ¦ #> ¦ Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 25-44 years : ¦ 56,562 ¦ 7,277 ¦ 43,861 ¦ 72,942 ¦ 5.5 ¦ 0.6 ¦ 4.3 ¦ 6.8 ¦ #> ¦ Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 45-64 years : ¦ 133,528 ¦ 12,956 ¦ 110,319 ¦ 161,619 ¦ 12.9 ¦ 1   ¦ 10.9 ¦ 15.1 ¦ #> ¦ Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65-74 years : ¦ 86,766 ¦ 6,767 ¦ 74,409 ¦ 101,176 ¦ 8.4 ¦ 0.6 ¦ 7.2 ¦ 9.7 ¦ #> ¦ Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 75 years and ¦ 72,896 ¦ 6,661 ¦ 60,872 ¦ 87,296 ¦ 7   ¦ 0.6 ¦ 5.9 ¦ 8.3 ¦ #> ¦ over : Male ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ #> +---------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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":"(Nothing.)","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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 41 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int 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: Age group: overwriting a variable that already exists. tab(\"Age group\") #> Age group {NAMCS 2019 PUF} #> +-------------------------------------------------------------------------------------------+ #> ¦ Level ¦ Number (000) ¦ SE (000) ¦ LL (000) ¦ UL (000) ¦ Percent ¦ SE ¦ LL ¦ UL ¦ #> +-------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ Under 1 ¦ 31,148 ¦ 5,282 ¦ 22,269 ¦ 43,566 ¦ 3   ¦ 0.5 ¦ 2.1 ¦ 4.1 ¦ #> +-------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 1-4 ¦ 38,240 ¦ 5,444 ¦ 28,864 ¦ 50,662 ¦ 3.7 ¦ 0.5 ¦ 2.7 ¦ 4.8 ¦ #> +-------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 5-14 ¦ 48,529 ¦ 5,741 ¦ 38,430 ¦ 61,282 ¦ 4.7 ¦ 0.5 ¦ 3.7 ¦ 5.9 ¦ #> +-------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 15-64 ¦ 544,632 ¦ 36,082 ¦ 478,254 ¦ 620,223 ¦ 52.5 ¦ 2   ¦ 48.6 ¦ 56.5 ¦ #> +-------------+--------------+----------+----------+----------+---------+-----+------+------¦ #> ¦ 65 and over ¦ 373,935 ¦ 24,523 ¦ 328,777 ¦ 425,296 ¦ 36.1 ¦ 1.9 ¦ 32.3 ¦ 40   ¦ #> +-------------------------------------------------------------------------------------------+ #> (Checked presentation standards. Nothing to report.) #>"},{"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, screen = getOption(\"surveytable.screen\"), 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? screen print screen? 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":"data.frame","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(\"vars2019\") #> _ #> Survey name NAMCS 2019 PUF #> Number of variables 41 #> Number of observations 8250 #> Stratified 1 - level Cluster Sampling design (with replacement) #> With (398) clusters. #> svydesign(ids = ~CPSUM, strata = ~CSTRATM, weights = ~PATWT, #> data = d1) #> * To adjust how counts are rounded, see ?set_count_int 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 ¦ #> +-----------+---------+------------------------------------------¦ #> ¦ Age group ¦ factor ¦ Age group ¦ #> +-----------+---------+------------------------------------------¦ #> ¦ Age x Sex ¦ factor ¦ (Patient age recode) x (Patient sex) ¦ #> +----------------------------------------------------------------+ #>"}] diff --git a/vignettes/surveytable.Rmd b/vignettes/surveytable.Rmd index eaa8daa..4b77785 100644 --- a/vignettes/surveytable.Rmd +++ b/vignettes/surveytable.Rmd @@ -14,7 +14,7 @@ knitr::opts_chunk$set( ) ``` -`surveytable` provides easy commands that generate tabulated and formatted survey estimates. +The `surveytable` package provides short and understandable commands that generate tabulated, formatted, and rounded survey estimates. The examples below use the National Ambulatory Medical Care Survey (NAMCS) 2019 Public Use File (PUF). NAMCS is "an annual nationally representative sample survey of visits to nonfederal office-based patient care physicians, excluding anesthesiologists, radiologists, and pathologists." Note that the unit of observation is visits, not patients – this distinction is important since a single patient can make multiple visits.