View source: R/svyCreateTableOne.R

svyCreateTableOne | R Documentation |

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.

svyCreateTableOne( vars, strata, data, factorVars, includeNA = FALSE, test = TRUE, testApprox = svyTestChisq, argsApprox = NULL, testNormal = svyTestNormal, argsNormal = list(method = "Wald"), testNonNormal = svyTestNonNormal, argsNonNormal = NULL, smd = TRUE, addOverall = FALSE )

`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. Do not include factors, unless you need to relevel them by removing empty levels. If omitted, only factors are considered categorical variables. 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. |

`addOverall` |
(optional, only used if strata are supplied) Adds an overall column to the table. Smd and p-value calculations are performed using only the stratifed clolumns. |

See the details for `CreateTableOne`

.

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 |

Kazuki Yoshida

`print.TableOne`

, `summary.TableOne`

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

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.