cat.var | R Documentation |
This function produces counts, row percentages, column percentages, and counts of missing values for each level of a categorical variable input, optionally stratified by another variable, and with the option to compute p-values.
cat.var(var, strat, dec, rownames, header, ptype, pname, cat.rmstat, vspace, output)
var |
Categorical variable input. Required. |
strat |
Column stratifying variable. Optional. |
dec |
Number of decimal places on summary statistics. Optional; defaults to 2. |
rownames |
Ordered character vector of row names for each level of 'var'. Optional; defaults to the value of each factor level. |
header |
Character vector providing a short variable description. Optional; defaults to variable name. |
ptype |
Statistical test for p-value. Optional; defaults to none. See |
pname |
If TRUE then the name of the statistical test used will be printed below the p-value. Optional; defaults to FALSE. |
cat.rmstat |
Vector naming the statistics that should be removed from the summary data frame. Optional; defaults to none.
|
vspace |
TRUE for additional vertical whitespace between variables (default). |
output |
Output type passed from |
Returns a data frame of categorical summary statistics.
Erica Wozniak
Table1
cont.var
make.table
quick.table
stat.col
out.plain
out.latex
out.html
library(survival) # Default output cat.var(var = pbc$hepato, strat = pbc$sex ) # Naming options and p-value cat.var(var = pbc$hepato, strat = pbc$sex, rownames = c("Not present", "Present"), header = c("Hepatomegaly"), ptype = "chisq" ) # Remove row percents, missing values, and name of statistical test used cat.var(var = pbc$hepato, strat = pbc$sex, rownames = c("Not present", "Present"), header = c("Hepatomegaly"), ptype = "chisq", cat.rmstat = c("row", "miss"), pname = FALSE )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.