tableNominal {reporttools} | R Documentation |
Many data analyses start with a display of descriptive statistics of important variables. This function takes a list of nominal variables and a possible grouping variable (such as e.g. treatment) and provides a LaTeX table of descriptive statistics separately per group and jointly for all observations, per variable.
tableNominal(vars, nams, group, subset = NA, miss.cat = NA, print.pval = c("none", "fisher", "chi2")[1], vertical = TRUE, cap = "", lab = "")
vars |
A list of nominal variables. |
nams |
A vector of strings, containing the names corresponding to the variables in vars . These are the names
that appear in the LaTeX table. |
group |
Grouping variable, may be omitted. |
subset |
Only consider a subset of observations. |
miss.cat |
Vector specifying the factors in vars that should have their NA s transformed to a separate category. |
print.pval |
Give p-value of Fisher's exact or chi^2 test for a difference of distributions between groups, if there is more than one group. |
vertical |
If TRUE , add vertical lines to the table, separating labels and groups, if applicable. |
cap |
The caption of the resulting LaTeX table. |
lab |
The label of the resulting LaTeX table. |
Outputs the LaTeX table.
Kaspar Rufibach (maintainer), kaspar.rufibach@gmail.com
Rufibach, K. (2009) reporttools: R-Functions to Generate LaTeX Tables of Descriptive Statistics. Journal of Statistical Software, to appear.
set.seed(1977) vars <- list(c(round(runif(90, 0, 3)), NA), round(runif(100, 0, 2))) nams <- c("Var1", "Var2") group <- sample(c(rep("A", 50), rep("B", 50))) subset <- c(1:70, 91:100) tableNominal(vars, nams, group, subset, cap = "Table of nominal variables.", lab = "tab: nominal")