EVOLUTION-MANAGER
Edit File: as_tabyl.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: Add 'tabyl' attributes to a data.frame.</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 as_tabyl {janitor}"><tr><td>as_tabyl {janitor}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Add <code>tabyl</code> attributes to a data.frame.</h2> <h3>Description</h3> <p>A <code>tabyl</code> is a data.frame containing counts of a variable or co-occurrences of two variables (a.k.a., a contingency table or crosstab). This specialized kind of data.frame has attributes that enable <code>adorn_</code> functions to be called for precise formatting and presentation of results. E.g., display results as a mix of percentages, Ns, add totals rows or columns, rounding options, in the style of Microsoft Excel PivotTable. </p> <p>A <code>tabyl</code> can be the result of a call to <code>janitor::tabyl()</code>, in which case these attributes are added automatically. This function adds <code>tabyl</code> class attributes to a data.frame that isn't the result of a call to <code>tabyl</code> but meets the requirements of a two-way tabyl: 1) First column contains values of variable 1 2) Column names 2:n are the values of variable 2 3) Numeric values in columns 2:n are counts of the co-occurrences of the two variables.* </p> <p>* = this is the ideal form of a tabyl, but janitor's <code>adorn_</code> functions tolerate and ignore non-numeric columns in positions 2:n. </p> <p>For instance, the result of <code>dplyr::count()</code> followed by <code>tidyr::spread()</code> can be treated as a <code>tabyl</code>. </p> <p>The result of calling <code>tabyl()</code> on a single variable is a special class of one-way tabyl; this function only pertains to the two-way tabyl. </p> <h3>Usage</h3> <pre> as_tabyl(dat, axes = 2, row_var_name = NULL, col_var_name = NULL) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>dat</code></td> <td> <p>a data.frame with variable values in the first column and numeric values in all other columns.</p> </td></tr> <tr valign="top"><td><code>axes</code></td> <td> <p>is this a two_way tabyl or a one_way tabyl? If this function is being called by a user, this should probably be "2". One-way tabyls are created by <code>tabyl</code> but are a special case.</p> </td></tr> <tr valign="top"><td><code>row_var_name</code></td> <td> <p>(optional) the name of the variable in the row dimension; used by <code>adorn_title()</code>.</p> </td></tr> <tr valign="top"><td><code>col_var_name</code></td> <td> <p>(optional) the name of the variable in the column dimension; used by <code>adorn_title()</code>.</p> </td></tr> </table> <h3>Value</h3> <p>Returns the same data.frame, but with the additional class of "tabyl" and the attribute "core". </p> <h3>Examples</h3> <pre> as_tabyl(mtcars) </pre> <hr /><div style="text-align: center;">[Package <em>janitor</em> version 2.1.0 <a href="00Index.html">Index</a>]</div> </body></html>