tabmulti.svy: Create Table Comparing Characteristics Across Levels of a...

Description Usage Arguments Details Value Examples

View source: R/archived/tabmulti_svy-2020-03-28.R View source: R/tabmulti_svy.R

Description

Creates a table comparing multiple characteristics (e.g. median age, mean BMI, and race/ethnicity distribution) across levels of x.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
tabmulti.svy(
  formula = NULL,
  design,
  xvarname = NULL,
  yvarnames = NULL,
  ymeasures = NULL,
  columns = c("xgroups", "p"),
  listwise.deletion = FALSE,
  sep.char = ", ",
  xlevels = NULL,
  yvarlabels = NULL,
  ylevels = NULL,
  decimals = NULL,
  formatp.list = NULL,
  n.headings = FALSE,
  N.headings = FALSE,
  kable = TRUE,
  tabmeans.svy.list = NULL,
  tabmedians.svy.list = NULL,
  tabfreq.svy.list = NULL
)

Arguments

formula

Formula, e.g. Age + Race + BMI ~ Sex.

design

Survey design object from svydesign.

xvarname

Character string with name of column variable. Should be one of names(design$variables).

yvarnames

Character vector with names of row variables. Each element should be one of names(design$variables).

ymeasures

Character vector specifying whether each y variable should be summarized by mean, median, or frequency. For example, if you want to compare frequencies for the first variable, means for the second, and medians for the third, you would set ymeasures = c("freq", "mean", "median"). If unspecified, function compares means for numeric variables and frequencies for factor and character variables.

columns

Character vector specifying what columns to include. Choices for each element are "n" for unweighted sample size, "N" for weighted sample size, "overall" for overall statistics, "xgroups" for x group statistics, and "p" for p-value.

listwise.deletion

Logical value for whether observations with missing values for any y variable should be excluded entirely (as opposed to using all available data for each comparison).

sep.char

Character string with separator to place between lower and upper bound of confidence intervals. Typically "-" or ", ".

xlevels

Character vector with labels for the levels of x, used in column headings.

yvarlabels

Named list specifying labels for certain y variables. For example, if you want variables named "race" and "age_yrs" to print as "Race/ethnicity" and "Age (years)", use \codeyvarlabels = list(race = "Race/ethnicity", age_yrs = "Age (years)").

ylevels

Character vector (if only 1 frequency comparison) or list of character vectors with labels for the levels of each categorical y variable.

decimals

Numeric vector specifying number of decimal places for numbers other than p-values for each y variable. Can be a single value to use for all y variables.

formatp.list

List of arguments to pass to formatp.

n.headings

Logical value for whether to display unweighted sample sizes in parentheses in column headings.

N.headings

Logical value for whether to display weighted sample sizes in parentheses in column headings.

kable

Logical value for whether to return a kable.

tabmeans.svy.list

List of arguments to pass to tabmeans.svy.

tabmedians.svy.list

List of arguments to pass to tabmedians.svy.

tabfreq.svy.list

List of arguments to pass to tabfreq.svy.

Details

Basically tabmulti for complex survey data. Relies heavily on the survey package.

Value

kable or character matrix.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Create survey design object
library("survey")
design <- svydesign(
  data = tabsvydata,
  ids = ~sdmvpsu,
  strata = ~sdmvstra,
  weights = ~wtmec2yr,
  nest = TRUE
)

# Compare age, race, and BMI by sex
tabmulti.svy(Age + Race + BMI ~ Sex, design)

tab documentation built on Aug. 2, 2021, 9:06 a.m.