View source: R/CreateTableOneJS.R

CreateTableOneJS | R Documentation |

Combine CreateTableOne & print function in tableone package

```
CreateTableOneJS(
vars,
strata = NULL,
strata2 = NULL,
data,
factorVars = NULL,
includeNA = F,
test = T,
testApprox = chisq.test,
argsApprox = list(correct = TRUE),
testExact = fisher.test,
argsExact = list(workspace = 2 * 10^5),
testNormal = oneway.test,
argsNormal = list(var.equal = F),
testNonNormal = kruskal.test,
argsNonNormal = list(NULL),
showAllLevels = T,
printToggle = F,
quote = F,
smd = F,
Labels = F,
exact = NULL,
nonnormal = NULL,
catDigits = 1,
contDigits = 2,
pDigits = 3,
labeldata = NULL,
psub = T,
minMax = F,
showpm = T
)
```

`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. |

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

`strata2` |
Stratifying 2nd grouping variable name(s) given as a character vector. If omitted, the 1 group results are returned. |

`data` |
A data frame in which these variables exist. All variables (both vars and strata) must be in this data frame. |

`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 |

`testApprox` |
A function used to perform the large sample approximation based tests. The default is chisq.test. This is not recommended when some of the cell have small counts like fewer than 5, Default: chisq.test |

`argsApprox` |
A named list of arguments passed to the function specified in testApprox. The default is list(correct = TRUE), which turns on the continuity correction for chisq.test, Default: list(correct = TRUE) |

`testExact` |
A function used to perform the exact tests. The default is fisher.test. If the cells have large numbers, it will fail because of memory limitation. In this situation, the large sample approximation based should suffice., Default: fisher.test |

`argsExact` |
A named list of arguments passed to the function specified in testExact. The default is list(workspace = 2 * 10^5), which specifies the memory space allocated for fisher.test, Default: list(workspace = 2 * 10^5) |

`testNormal` |
A function used to perform the normal assumption based tests. The default is oneway.test. This is equivalent of the t-test when there are only two groups, Default: oneway.test |

`argsNormal` |
A named list of arguments passed to the function specified in testNormal. The default is list(var.equal = TRUE), which makes it the ordinary ANOVA that assumes equal variance across groups., Default: list(var.equal = F) |

`testNonNormal` |
A function used to perform the nonparametric tests. The default is kruskal.test (Kruskal-Wallis Rank Sum Test). This is equivalent of the wilcox.test (Man-Whitney U test) when there are only two groups, Default: kruskal.test |

`argsNonNormal` |
A named list of arguments passed to the function specified in testNonNormal. The default is list(NULL), which is just a placeholder., Default: list(NULL) |

`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 |

`Labels` |
Use Label, Default: F |

`exact` |
A character vector to specify the variables for which the p-values should be those of exact tests. By default all p-values are from large sample approximation tests (chisq.test)., Default: NULL |

`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 |

`labeldata` |
labeldata to use, Default: NULL |

`psub` |
show sub-group p-values, Default: F |

`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 |

DETAILS

A matrix object containing what you see is also invisibly returned. This can be assinged a name and exported via write.csv.

```
library(survival)
CreateTableOneJS(vars = names(lung), strata = "sex", data = lung)
```

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.