round_unit: Round a number or vector of numbers up or down to nice...

View source: R/rounding.R

round_unitR Documentation

Round a number or vector of numbers up or down to nice intervals

Description

Round numbers to nice intervals with the following options:

round_up

round up to the nearest power of 10

round_down

round down to the nearest power of 10

round_up_nice

round up to the nearest "nice" value. From http://stackoverflow.com/questions/6461209/how-to-round-up-to-the-nearest-10-or-100-or-x)

round_up_unit

round up x to the nearest b

round_down_unit

round x down to the nearest b

round_unit

round x up or down to the nearest b; direction depends on how close x is to b

log10_breaks

creates a vector evenly spaced on a log 10 scale: 10 points across each order of magnitude

Usage

round_unit(x, b)

Arguments

x

the number or vector of numbers to be rounded

b

the unit to round the number to (applies to round_up_unit and round_down_unit only)

Value

a rounded number

Examples

round_up(c(4, 1, 101, 99, 1002))
round_down_unit(1.23, 0.1)
round_down_unit(x = c(4, 1, 101, 99, 1002), b = 25)



shirewoman2/Consultancy documentation built on Feb. 18, 2025, 10 p.m.