Add and Print Marginals for 2-way Contingency Tables
printTable2()
prints a 2-way contingency table “with all
bells and whistles” (currently using German labeling).
margin2table()
computes marginals, adds them to the table and
returns a margin2table
object the print method for which adds
text decorations (using "-"
and "|"
).
printTable2(table2, digits = 3) margin2table(x, totName = "sum", name.if.empty=FALSE) ## S3 method for class 'margin2table' print(x, digits = 3, quote = FALSE, right = TRUE, ...)
table2 |
a matrix with non-negative integer entries, i.e. the contingency table. |
x |
a matrix; for |
digits |
Anzahl Dezimalstellen, auf die die Häufigkeiten gerundet werden sollen. |
quote, right |
logicals passed to |
totName |
string to use as row- and column- name if |
name.if.empty |
logical indicating if the margin “totals” should be named in any case. |
... |
further potential arguments, unused currently. |
margin2table
returns a matrix with added marginals,
i.e., an extra row and column, and is of class "margin2table"
(and "table"
still) which has a nice print method.
printTable2
is just producing output.
Martin Maechler, Feb.1993; then Dec 2003
margin2table(diag(4),,TRUE) m <- diag(3); colnames(m) <- letters[1:3] margin2table(m) margin2table(m / sum(m)) data(HairEyeColor) margin2table(HairEyeColor[,, "Male"]) printTable2(HairEyeColor[,, "Male"]) printTable2(HairEyeColor[,, "Female"])
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.