Description Usage Arguments Value Warning Note Author(s) References Examples
Many data analyses start with a display of descriptive statistics of important variables. This function takes a data frame of nominal variables and possible grouping (such as e.g. treatment), weighting, and subset variables and provides a LaTeX table of descriptive statistics separately per group and jointly for all observations, per variable.
1 2 3 4 5 6  tableNominal(vars, weights = NA, subset = NA,
group = NA, miss.cat = NA, print.pval = c("none", "fisher",
"chi2"), pval.bound = 10^4, fisher.B = 2000, vertical = TRUE,
cap = "", lab = "", col.tit.font = c("bf", "", "sf", "it", "rm"),
font.size = "footnotesize", longtable = TRUE, nams = NA,
cumsum = TRUE, ...)

vars 
A data frame of nominal variables. See 
weights 
Optional vector of weights of each observation. 
subset 
Optional logical vector, indicates subset of observations to be used. 
group 
Optional grouping variable. 
miss.cat 
Vector specifying the factors in 
print.pval 
Add pvalues of Fisher's exact or χ^2 test for a difference of distributions between groups to the table, if there is more than one group. Note that by default, any missing values are removed for computation of pvalues. If missings should be considered a separate level, define the input variables accordingly. 
pval.bound 
pvalues below 
fisher.B 
Number of simulations to compute pvalue for Fisher's exact test. Note that in the function

vertical 
If 
cap 
The caption of the resulting LaTeX table. 
lab 
The label of the resulting LaTeX table. 
col.tit.font 
Choose the font for the column titles here (default: boldface). 
font.size 
Font size for the generated table in LaTeX. 
longtable 
If 
nams 
A vector of strings, containing the names corresponding to the variables in 
cumsum 
If 
... 
Arguments pass through to 
Outputs the LaTeX table.
If either one of the arguments group
, weights
, or subset
is different from NA
and if vars
is a list, then it is assumed that all variables
in vars
are of equal length.
If longtable = TRUE
(which is the default), the function generates a table that may be more than one page
long, you need to include the package longtable in the LaTeX source.
If a list of variables is given to vars
, not all of these variables need to be of the same length. However,
note the Warning above.
Kaspar Rufibach (maintainer), kaspar.rufibach@gmail.com,
http://www.kasparrufibach.ch
Rufibach, K. (2009)
reporttools: RFunctions to Generate LaTeX Tables of Descriptive Statistics.
Journal of Statistical Software, Code Snippets, 31(1).
doi: 10.18637/jss.v031.c01.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41  data(CO2)
vars < CO2[, 1:2]
group < CO2[, "Treatment"]
weights < c(rep(1, 60), rep(0, 10), rep(2, 14))
## first all observations
tableNominal(vars = vars, weights = weights, group = group, cap =
"Table of nominal variables.", lab = "tab: nominal")
## do not include cumulative percentages
tableNominal(vars = vars, weights = weights, group = group, cap =
"Table of nominal variables.", lab = "tab: nominal", cumsum = FALSE)
## but include pvalue for Fisher's exact test
tableNominal(vars = vars, weights = weights, group = group, cap =
"Table of nominal variables.", lab = "tab: nominal",
print.pval = "fisher", cumsum = FALSE)
## Fisher's exact test without simulated pvalue
tableNominal(vars = vars, weights = weights, group = group, cap =
"Table of nominal variables.", lab = "tab: nominal",
print.pval = "fisher", fisher.B = Inf, cumsum = FALSE)
## then only consider a subset of observations
subset < c(1:50, 60:70)
tableNominal(vars = vars, weights = weights, subset = subset, group = group,
cap = "Table of nominal variables.", lab = "tab: nominal")
## do not include cumulative percentages
tableNominal(vars = vars, weights = weights, subset = subset, group = group,
cap = "Table of nominal variables.", lab = "tab: nominal", cumsum = FALSE)
## Not run:
## caption placement at the top and repeat column headings on top of each page
## in the longtable format. Have to manually add another backslash to hline and endhead
## below (they are removed when compiling the help file)!
tableNominal(vars = vars, cap = "Table of nominal variables.", cumsum = FALSE,
caption.placement = "top", longtable = TRUE, add.to.row = list(pos = list(0),
command = "\hline \endhead ")
## End(Not run)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.