rounds a numeric value to any arbitrary degree of precision. defaults to nearest whole integer

round_any(x, accuracy = 1)

Arguments

x

a numeric vector

accuracy

a numeric value specifying the base for rounding

Value

a vector of the same length as x rounded to the defined accuracy

Examples

round_any(c(1, 1.25, 1.5, 1.75, 2), accuracy = 0.5)
#> [1] 1.0 1.0 1.5 2.0 2.0