| 1 |
\name{printTable2} |
| 2 |
% source in ../R/printTable.R |
| 3 |
\alias{printTable2} |
| 4 |
\alias{margin2table} |
| 5 |
\alias{print.margin2table} |
| 6 |
\title{Add and Print Marginals for 2-way Contingency Tables} |
| 7 |
%\title{Berechne und Drucke Randtotale etc für 2-weg Kontingenz Tafeln} |
| 8 |
\description{ |
| 9 |
\code{printTable2()} prints a 2-way contingency table \dQuote{with all |
| 10 |
bells and whistles} (currently using German labeling). |
| 11 |
|
| 12 |
\code{margin2table()} computes marginals, adds them to the table and |
| 13 |
returns a \code{margin2table} object the print method for which adds |
| 14 |
text decorations (using \code{"-"} and \code{"|"}). |
| 15 |
} |
| 16 |
\usage{ |
| 17 |
printTable2(table2, digits = 3) |
| 18 |
margin2table(x, totName = "sum", name.if.empty=FALSE) |
| 19 |
\method{print}{margin2table}(x, digits = 3, quote = FALSE, right = TRUE, \dots) |
| 20 |
} |
| 21 |
\arguments{ |
| 22 |
\item{table2}{a matrix with non-negative integer entries, i.e. the |
| 23 |
contingency table.}%Matrix mit Anzahlen, die Kontingenztafel. |
| 24 |
\item{x}{a matrix; for \code{print()}, the result of \code{margin2table}.} |
| 25 |
\item{digits}{Anzahl Dezimalstellen, auf die die Häufigkeiten gerundet |
| 26 |
werden sollen.} |
| 27 |
\item{quote, right}{logicals passed to \code{\link{print.default}()}, |
| 28 |
but with different default values.} |
| 29 |
\item{totName}{string to use as row- and column- name if \code{x} has |
| 30 |
corresponding \code{\link{dimnames}}.} |
| 31 |
\item{name.if.empty}{logical indicating if the margin \dQuote{totals} |
| 32 |
should be named in any case.} |
| 33 |
\item{\dots}{further potential arguments, unused currently.} |
| 34 |
} |
| 35 |
% \details{ |
| 36 |
% ......... |
| 37 |
% } |
| 38 |
\value{ |
| 39 |
\code{margin2table} returns a matrix with \emph{added marginals}, |
| 40 |
i.e., an extra row and column, and is of class \code{"margin2table"} |
| 41 |
(and \code{"\link{table}"} still) which has a nice print method. |
| 42 |
|
| 43 |
\code{printTable2} is just producing output. |
| 44 |
} |
| 45 |
\author{Martin Maechler, Feb.1993; then Dec 2003} |
| 46 |
\seealso{\code{\link{table}}, \code{\link{ftable}}.} |
| 47 |
|
| 48 |
\examples{ |
| 49 |
margin2table(diag(4),,TRUE) |
| 50 |
m <- diag(3); colnames(m) <- letters[1:3] |
| 51 |
margin2table(m) |
| 52 |
margin2table(m / sum(m)) |
| 53 |
|
| 54 |
data(HairEyeColor) |
| 55 |
margin2table(HairEyeColor[,, "Male"]) |
| 56 |
printTable2(HairEyeColor[,, "Male"]) |
| 57 |
printTable2(HairEyeColor[,, "Female"]) |
| 58 |
} |
| 59 |
\keyword{utilities} |
| 60 |
|