50% off | Unlimited Data & AI Learning
Get 50% off unlimited learning

cards (version 0.5.1)

round5: Rounding of Numbers

Description

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, cards::round5(0.5) = 1, whereas base::round(0.5) = 0.

Usage

round5(x, digits = 0)

Value

a numeric vector

Arguments

x

(numeric)
a numeric vector

digits

(integer)
integer indicating the number of decimal places

Details

Function inspired by janitor::round_half_up().

Examples

Run this code
x <- 0:4 / 2
round5(x) |> setNames(x)

# compare results to Base R
round(x) |> setNames(x)

Run the code above in your browser using DataLab