EVOLUTION-MANAGER
Edit File: 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: Generate a frequency table (1-, 2-, or 3-way).</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 tabyl {janitor}"><tr><td>tabyl {janitor}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Generate a frequency table (1-, 2-, or 3-way).</h2> <h3>Description</h3> <p>A fully-featured alternative to <code>table()</code>. Results are data.frames and can be formatted and enhanced with janitor's family of <code>adorn_</code> functions. </p> <p>Specify a data.frame and the one, two, or three unquoted column names you want to tabulate. Three variables generates a list of 2-way tabyls, split by the third variable. </p> <p>Alternatively, you can tabulate a single variable that isn't in a data.frame by calling <code>tabyl</code> on a vector, e.g., <code>tabyl(mtcars$gear)</code>. </p> <h3>Usage</h3> <pre> tabyl(dat, ...) ## Default S3 method: tabyl(dat, show_na = TRUE, show_missing_levels = TRUE, ...) ## S3 method for class 'data.frame' tabyl(dat, var1, var2, var3, show_na = TRUE, show_missing_levels = TRUE, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>dat</code></td> <td> <p>a data.frame containing the variables you wish to count. Or, a vector you want to tabulate.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>the arguments to tabyl (here just for the sake of documentation compliance, as all arguments are listed with the vector- and data.frame-specific methods)</p> </td></tr> <tr valign="top"><td><code>show_na</code></td> <td> <p>should counts of <code>NA</code> values be displayed? In a one-way tabyl, the presence of <code>NA</code> values triggers an additional column showing valid percentages(calculated excluding <code>NA</code> values).</p> </td></tr> <tr valign="top"><td><code>show_missing_levels</code></td> <td> <p>should counts of missing levels of factors be displayed? These will be rows and/or columns of zeroes. Useful for keeping consistent output dimensions even when certain factor levels may not be present in the data.</p> </td></tr> <tr valign="top"><td><code>var1</code></td> <td> <p>the column name of the first variable.</p> </td></tr> <tr valign="top"><td><code>var2</code></td> <td> <p>(optional) the column name of the second variable (the rows in a 2-way tabulation).</p> </td></tr> <tr valign="top"><td><code>var3</code></td> <td> <p>(optional) the column name of the third variable (the list in a 3-way tabulation).</p> </td></tr> </table> <h3>Value</h3> <p>Returns a data.frame with frequencies and percentages of the tabulated variable(s). A 3-way tabulation returns a list of data.frames. </p> <h3>Examples</h3> <pre> tabyl(mtcars, cyl) tabyl(mtcars, cyl, gear) tabyl(mtcars, cyl, gear, am) # or using the %>% pipe mtcars %>% tabyl(cyl, gear) # illustrating show_na functionality: my_cars <- rbind(mtcars, rep(NA, 11)) my_cars %>% tabyl(cyl) my_cars %>% tabyl(cyl, show_na = FALSE) # Calling on a single vector not in a data.frame: val <- c("hi", "med", "med", "lo") tabyl(val) </pre> <hr /><div style="text-align: center;">[Package <em>janitor</em> version 2.1.0 <a href="00Index.html">Index</a>]</div> </body></html>