apply_rounding: Apply a rounding rule

View source: R/rounding.R

apply_roundingR Documentation

Apply a rounding rule

Description

Apply a rounding rule

Usage

apply_rounding(x, rule = NA, digits = NA, increment = NA)

Arguments

x

A numeric vector.

rule

A character string naming the rounding rule. Supported values are "none", "round", "floor", "ceiling", "nearest_dollar", "nearest_cent", "nearest_dime", and "nearest_increment". A missing value also leaves x unchanged.

digits

The number of decimal places used when rule = "round". A missing value defaults to zero.

increment

The numeric increment used when rule = "nearest_increment".

Value

A numeric vector containing the rounded values. If rule is missing or "none", x is returned unchanged.

Examples

premiums <- c(101.234, 105.678)

apply_rounding(
  premiums,
  rule = "nearest_cent"
)

apply_rounding(
  premiums,
  rule = "nearest_increment",
  increment = 5
)

ratingtables documentation built on Sept. 6, 2026, 1:06 a.m.