"ftable"(formula, data = NULL, subset, na.action, ...)model.frame) containing the variables
to be cross-tabulated, or a contingency table (see below).data is a contingency table.NAs.
Ignored if data is a contingency table.ftable.default.ftable. The left and right hand side of formula specify the column and
row variables, respectively, of the flat contingency table to be
created. Only the + operator is allowed for combining the
variables. A . may be used once in the formula to indicate
inclusion of all the remaining variables.
If data is an object of class "table" or an array with
more than 2 dimensions, it is taken as a contingency table, and hence
all entries should be nonnegative. Otherwise, if it is not a flat
contingency table (i.e., an object of class "ftable"), it
should be a data frame or matrix, list or environment containing the
variables to be cross-tabulated. In this case, na.action is
applied to the data to handle missing values, and, after possibly
selecting a subset of the data as specified by the subset
argument, a contingency table is computed from the variables.
The contingency table is then collapsed to a flat table, according to
the row and column variables specified by formula.
ftable,
ftable.default;
table.
Titanic
x <- ftable(Survived ~ ., data = Titanic)
x
ftable(Sex ~ Class + Age, data = x)
Run the code above in your browser using DataLab