displayKbyC {reporttools} | R Documentation |
Function to display a K x C frequency table including col- and row-names and totals
Description
Generate a LaTeX table of a K \times C
frequency table that contains not only the cell frequencies, but also
pre-specified row- and col-names as well as totals of rows and cols.
Usage
displayKbyC(v1, v2, percentage = c("none", "row", "col",
"total")[1], names = c("v1", "v2"), cap = "",
lab = "", row.nam = NA, col.nam = NA)
Arguments
v1 |
Vector with |
v2 |
Vector with |
percentage |
Add percentages with respect to row, column, or table total. |
names |
Names of the vectors under consideration. |
cap |
Caption of the LaTeX table to be generated. |
lab |
Label of the LaTeX table to be generated. |
row.nam |
Labels of |
col.nam |
Labels of |
Value
Returns a LaTeX K x C table, together with the resulting computations. If you use this function in an .rnw file, you need to assign it to a (dummy) variable name in order for the results beyond the LaTeX table not to appear in the .tex file.
Author(s)
Kaspar Rufibach (maintainer), kaspar.rufibach@gmail.com,
http://www.kasparrufibach.ch
Examples
set.seed(1977)
v1 <- round(runif(20, 0, 3))
v2 <- round(runif(20, 0, 5))
displayKbyC(v1, v2, percentage = "row", names = c("v1", "v2"),
cap = "", lab = "", row.nam = NA, col.nam = NA)