View source: R/svyCreateTableOneJS.R
svyCreateTableOne2 | R Documentation |
Combine svyCreateTableOne & print function in tableone package
svyCreateTableOne2(
data,
strata,
vars,
factorVars,
includeNA = F,
test = T,
showAllLevels = T,
printToggle = F,
quote = F,
smd = F,
nonnormal = NULL,
catDigits = 1,
contDigits = 2,
pDigits = 3,
Labels = F,
labeldata = NULL,
minMax = F,
showpm = T,
addOverall = F
)
data |
A data frame in which these variables exist. All variables (both vars and strata) must be in this data frame. |
strata |
Stratifying (grouping) variable name(s) given as a character vector. If omitted, the overall results are returned. |
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 data frame specified in the data argument are used. |
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 vars argument. |
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., Default: F |
test |
If TRUE, as in the default and there are more than two groups, groupwise comparisons are performed, Default: T |
showAllLevels |
Whether to show all levels. FALSE by default, i.e., for 2-level categorical variables, only the higher level is shown to avoid redundant information., Default: T |
printToggle |
Whether to print the output. If FALSE, no output is created, and a matrix is invisibly returned., Default: F |
quote |
Whether to show everything in quotes. The default is FALSE. If TRUE, everything including the row and column names are quoted so that you can copy it to Excel easily, Default: F |
smd |
If TRUE, as in the default and there are more than two groups, standardized mean differences for all pairwise comparisons are calculated, Default: F |
nonnormal |
A character vector to specify the variables for which the p-values should be those of nonparametric tests. By default all p-values are from normal assumption-based tests (oneway.test)., Default: NULL |
catDigits |
Number of digits to print for proportions., Default: 1 |
contDigits |
Number of digits to print for continuous variables. Default 2. |
pDigits |
Number of digits to print for p-values (also used for standardized mean differences), Default: 3 |
Labels |
Use Label, Default: F |
labeldata |
labeldata to use, Default: NULL |
minMax |
Whether to use [min,max] instead of [p25,p75] for nonnormal variables. The default is FALSE. |
showpm |
Logical, show normal distributed continuous variables as Mean ± SD. Default: T |
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. Default: F |
DETAILS
A matrix object containing what you see is also invisibly returned. This can be assinged a name and exported via write.csv.
library(survey)
data(nhanes)
nhanes$SDMVPSU <- as.factor(nhanes$SDMVPSU)
nhanesSvy <- svydesign(
ids = ~SDMVPSU, strata = ~SDMVSTRA, weights = ~WTMEC2YR,
nest = TRUE, data = nhanes
)
svyCreateTableOne2(
vars = c("HI_CHOL", "race", "agecat", "RIAGENDR"),
strata = "RIAGENDR", data = nhanesSvy,
factorVars = c("HI_CHOL", "race", "RIAGENDR")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.