round5 | R Documentation |
Rounds the values in its first argument to the specified number of
decimal places (default 0). Importantly, round5()
does not use Base R's
"round to even" default. Standard rounding methods are implemented, for example,
round5(0.5) = 1
.
round5(x, digits = 0)
x |
( |
digits |
( |
Function inspired by janitor::round_half_up()
.
a numeric vector
x <- 0:4 / 2
round5(x) |> setNames(x)
# compare results to Base R
round(x) |> setNames(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.