round_any: Rounding to an Arbitrary Value

View source: R/round_any.R

round_anyR Documentation

Rounding to an Arbitrary Value

Description

Outputs a sequence of numbers in which a given vector is close to a sequence of numbers in which an arbitrary value (positive) is specified and that value is the equal difference. You can choose how to apply the close values by specifying ceiling or floor as the type argument to make it behave like rounding up or down. If the value matches an arbitrary isoperimetric sequence, the value will be output as is. round_any_ceiling is a simplified version of round_any, which outputs the result with the argument of type fixed to ceiling and origin fixed to 0. round_any_floor is a simplified version of round_any, where the type argument is fixed to floor and the origin is fixed to 0. round_any_* is faster than round_any in most cases, because the internal processing is done as a vector. However, in rare cases, round_any_* may not be possible to obtain accurate values because of R's internal floating point arithmetic. round_any creates a sequence of numbers and compares them, so it gives accurate rounding results.

Usage

round_any(x, by, type = c("ceiling", "floor"), origin = 0)

round_any_ceiling(x, by)

round_any_floor(x, by)

Arguments

x

a numeric vector.

by

Specify a positive value for the isoperimetric difference of the sequence of isoperimetric numbers for which you want to obtain an approximation.

type

Specifies whether the value to be rounded is below or above the nearest value.

origin

Specifies the first term of an identity sequence to be compared. The default value is 0.


indenkun/infun documentation built on April 17, 2025, 2:52 p.m.