round_to_next_multiple: Round towards a multiple of n

Description Usage Arguments Note Examples

View source: R/round.R

Description

Round x up or down to the nearest multiple of n.

Usage

1
2
3
4
5

Arguments

x

The value to round.

n

The value which determines the rounding target.

Note

Symmetrical rounding to the next power of ten can also be archived using round with a negative digits argument.

Examples

1
2
3
4
round_to_next_multiple(120, 50)  # 100
round_to_next_multiple(17, 5)  # 15
floor_to_next_multiple(195, 100)  # 100
ceiling_to_next_multiple(10.3, 2)  # 12

BastiHz/BastiHzR documentation built on March 24, 2021, 1:48 p.m.