Rev 7606 | Blame | Last modification | View Log | Download | RSS feed
\name{ftable.formula}\alias{ftable.formula}\title{Formula Notation for Flat Contingency Tables}\description{Produce or manipulate a flat contingency table usingformula notation.}\usage{\method{ftable}{formula}(formula, data = NULL, subset, na.action, \dots)}\arguments{\item{formula}{a formula object with both left and right hand sidesspecifying the column and row variables of the flat table.}\item{data}{a data frame, list or environment containing the variablesto be cross-tabulated, or a contingency table (see below).}\item{subset}{an optional vector specifying a subset of observationsto be used.Ignored if \code{data} is a contingency table.}\item{na.action}{a function which indicates what should happen whenthe data contain \code{NA}s.Ignored if \code{data} is a contingency table.}\item{\dots}{further arguments to the default ftable method may alsobe passed as arguments, see \code{\link{ftable.default}}.}}\details{This is a method of the generic function \code{\link{ftable}}.The left and right hand side of \code{formula} specify the column androw variables, respectively, of the flat contingency table to becreated. Only the \code{+} operator is allowed for combining thevariables. A \code{.} may be used once in the formula to indicateinclusion of all the ``remaining'' variables.If \code{data} is an object of class \code{"table"} or an array withmore than 2 dimensions, it is taken as a contingency table, and henceall entries should be nonnegative. Otherwise, if it is not a flatcontingency table (i.e., an object of class \code{"ftable"}), itshould be a data frame or matrix, list or environment containing thevariables to be cross-tabulated. In this case, \code{na.action} isapplied to the data to handle missing values, and, after possiblyselecting a subset of the data as specified by the \code{subset}argument, a contingency table is computed from the variables.The contingency table is then collapsed to a flat table, according tothe row and column variables specified by \code{formula}.}\value{A flat contingency table which contains the counts of each combinationof the levels of the variables, collapsed into a matrix for suitablydisplaying the counts.}\seealso{\code{\link{ftable}},\code{\link{ftable.default}};\code{\link{table}}.}\examples{data(Titanic)Titanicx <- ftable(Survived ~ ., data = Titanic)xftable(Sex ~ Class + Age, data = x)}\keyword{category}