EVOLUTION-MANAGER
Edit File: adorn_rounding.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: Round the numeric columns in 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 adorn_rounding {janitor}"><tr><td>adorn_rounding {janitor}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Round the numeric columns in a data.frame.</h2> <h3>Description</h3> <p>Can run on any data.frame with at least one numeric column. This function defaults to excluding the first column of the input data.frame, assuming that it contains a descriptive variable, but this can be overridden by specifying the columns to round in the <code>...</code> argument. </p> <p>If you're formatting percentages, e.g., the result of <code>adorn_percentages()</code>, use <code>adorn_pct_formatting()</code> instead. This is a more flexible variant for ad-hoc usage. Compared to <code>adorn_pct_formatting()</code>, it does not multiply by 100 or pad the numbers with spaces for alignment in the results data.frame. This function retains the class of numeric input columns. </p> <h3>Usage</h3> <pre> adorn_rounding(dat, digits = 1, rounding = "half to even", ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>dat</code></td> <td> <p>a <code>tabyl</code> or other data.frame with similar layout. If given a list of data.frames, this function will apply itself to each data.frame in the list (designed for 3-way <code>tabyl</code> lists).</p> </td></tr> <tr valign="top"><td><code>digits</code></td> <td> <p>how many digits should be displayed after the decimal point?</p> </td></tr> <tr valign="top"><td><code>rounding</code></td> <td> <p>method to use for rounding - either "half to even", the base R default method, or "half up", where 14.5 rounds up to 15.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>columns to adorn. This takes a tidyselect specification. By default, all numeric columns (besides the initial column, if numeric) are adorned, but this allows you to manually specify which columns should be adorned, for use on a data.frame that does not result from a call to <code>tabyl</code>.</p> </td></tr> </table> <h3>Value</h3> <p>Returns the data.frame with rounded numeric columns. </p> <h3>Examples</h3> <pre> mtcars %>% tabyl(am, cyl) %>% adorn_percentages() %>% adorn_rounding(digits = 2, rounding = "half up") # tolerates non-numeric columns: library(dplyr) mtcars %>% tabyl(am, cyl) %>% adorn_percentages("all") %>% mutate(dummy = "a") %>% adorn_rounding() # Control the columns to be adorned with the ... variable selection argument # If using only the ... argument, you can use empty commas as shorthand # to supply the default values to the preceding arguments: cases <- data.frame( region = c("East", "West"), year = 2015, recovered = c(125, 87), died = c(13, 12) ) cases %>% adorn_percentages(,,ends_with("ed")) %>% adorn_rounding(,,one_of(c("recovered", "died"))) </pre> <hr /><div style="text-align: center;">[Package <em>janitor</em> version 2.1.0 <a href="00Index.html">Index</a>]</div> </body></html>