EVOLUTION-MANAGER
Edit File: ftable.formula.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Formula Notation for Flat Contingency Tables</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for ftable.formula {stats}"><tr><td>ftable.formula {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Formula Notation for Flat Contingency Tables</h2> <h3>Description</h3> <p>Produce or manipulate a flat contingency table using formula notation.</p> <h3>Usage</h3> <pre> ## S3 method for class 'formula' ftable(formula, data = NULL, subset, na.action, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>formula</code></td> <td> <p>a formula object with both left and right hand sides specifying the column and row variables of the flat table.</p> </td></tr> <tr valign="top"><td><code>data</code></td> <td> <p>a data frame, list or environment (or similar: see <code><a href="model.frame.html">model.frame</a></code>) containing the variables to be cross-tabulated, or a contingency table (see below).</p> </td></tr> <tr valign="top"><td><code>subset</code></td> <td> <p>an optional vector specifying a subset of observations to be used. Ignored if <code>data</code> is a contingency table.</p> </td></tr> <tr valign="top"><td><code>na.action</code></td> <td> <p>a function which indicates what should happen when the data contain <code>NA</code>s. Ignored if <code>data</code> is a contingency table.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>further arguments to the default ftable method may also be passed as arguments, see <code><a href="ftable.html">ftable.default</a></code>.</p> </td></tr> </table> <h3>Details</h3> <p>This is a method of the generic function <code><a href="ftable.html">ftable</a></code>. </p> <p>The left and right hand side of <code>formula</code> specify the column and row variables, respectively, of the flat contingency table to be created. Only the <code>+</code> operator is allowed for combining the variables. A <code>.</code> may be used once in the formula to indicate inclusion of all the remaining variables. </p> <p>If <code>data</code> is an object of class <code>"table"</code> 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 <code>"ftable"</code>), it should be a data frame or matrix, list or environment containing the variables to be cross-tabulated. In this case, <code>na.action</code> is applied to the data to handle missing values, and, after possibly selecting a subset of the data as specified by the <code>subset</code> argument, a contingency table is computed from the variables. </p> <p>The contingency table is then collapsed to a flat table, according to the row and column variables specified by <code>formula</code>. </p> <h3>Value</h3> <p>A flat contingency table which contains the counts of each combination of the levels of the variables, collapsed into a matrix for suitably displaying the counts. </p> <h3>See Also</h3> <p><code><a href="ftable.html">ftable</a></code>, <code><a href="ftable.html">ftable.default</a></code>; <code><a href="../../base/html/table.html">table</a></code>. </p> <h3>Examples</h3> <pre> Titanic x <- ftable(Survived ~ ., data = Titanic) x ftable(Sex ~ Class + Age, data = x) </pre> <hr /><div style="text-align: center;">[Package <em>stats</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>