# Create an object summarizing both continuous and categorical variables for weighted data

### Description

Create an object summarizing all baseline variables (both continuous and categorical) optionally stratifying by one or more startifying variables and performing statistical tests. The object gives a table that is easy to use in medical research papers.

### Usage

1 2 3 4 |

### Arguments

`vars` |
Variables to be summarized given as a character vector. Factors are handled as categorical variables, whereas numeric variables are handled as continuous variables. If empty, all variables in the survey design object specified in the data argument are used. |

`strata` |
Stratifying (grouping) variable name(s) given as a character vector. If omitted, the overall results are returned. |

`data` |
A survey design object in which these variables exist. All variables (both vars and strata) must be in this survey design object. It is created with the |

`factorVars` |
Numerically coded variables that should be handled as categorical variables given as a character vector. If omitted, only factors are considered categorical variables. If all categorical variables in the dataset are already factors, this option is not necessary. The variables specified here must also be specified in the |

`includeNA` |
If TRUE, NA is handled as a regular factor level rather than missing. NA is shown as the last factor level in the table. Only effective for categorical variables. |

`test` |
If TRUE, as in the default and there are more than two groups, groupwise comparisons are performed. |

`testApprox` |
A function used to perform the large sample approximation based tests. The default is |

`argsApprox` |
A named list of arguments passed to the function specified in testApprox. |

`testNormal` |
A function used to perform the normal assumption based tests. The default is multiple degrees of freedom test using |

`argsNormal` |
A named list of arguments passed to the function specified in |

`testNonNormal` |
A function used to perform the nonparametric tests. The default is |

`argsNonNormal` |
A named list of arguments passed to the function specified in |

`smd` |
If TRUE, as in the default and there are more than two groups, standardized mean differences for all pairwise comparisons are calculated. |

### Details

See the details for `CreateTableOne`

.

### Value

An object of class `svyTableOne`

, which is a list of three objects.

`ContTable` |
an object of class |

`CatTable` |
an object of class |

`MetaData` |
list of metadata regarding variables |

### Author(s)

Kazuki Yoshida

### See Also

`print.TableOne`

, `summary.TableOne`

### Examples

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | ```
## Load packages
library(tableone)
library(survey)
## Create a weighted survey design object
data(nhanes)
nhanesSvy <- svydesign(ids = ~ SDMVPSU, strata = ~ SDMVSTRA, weights = ~ WTMEC2YR,
nest = TRUE, data = nhanes)
## Create a table object
## factorVars are converted to factors; no need for variables already factors
## strata will stratify summaries; leave it unspecified for overall summaries
tab1 <- svyCreateTableOne(vars = c("HI_CHOL","race","agecat","RIAGENDR"),
strata = "RIAGENDR", data = nhanesSvy,
factorVars = c("race","RIAGENDR"))
## Detailed output
summary(tab1)
## Default formatted printing
tab1
## nonnormal specifies variables to be shown as median [IQR]
print(tab1, nonnormal = "HI_CHOL", contDigits = 3, catDigits = 2,
pDigits = 4, smd = TRUE)
## minMax changes it to median [min, max]
print(tab1, nonnormal = "HI_CHOL", minMax = TRUE, contDigits = 3,
catDigits = 2, pDigits = 4, smd = TRUE)
## showAllLevels can be used tow show levels for all categorical variables
print(tab1, showAllLevels = TRUE, smd = TRUE)
## To see all printing options
?print.TableOne
## To examine categorical variables only
tab1$CatTable
## To examine continuous variables only
tab1$ContTable
## If SMDs are needed as numericals, use ExtractSmd()
ExtractSmd(tab1)
``` |

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker. Vote for new features on Trello.