Learn R Programming

proporz (version 1.5.3)

ceil_at: Rounding with predefined thresholds

Description

Round x up to ceiling(x) if x-floor(x) >= threshold, otherwise round down to floor(x). Used for all divisor methods.

Usage

ceil_at(x, threshold)

Value

Rounded vector or matrix

Arguments

x

Numeric atomic vector or matrix with values >= 0 (NaN is not supported)

threshold

Numeric threshold value in [0,1] or "harmonic"/"geometric" to use harmonic or geometric mean thresholds

Examples

Run this code
ceil_at(c(0.5, 1.5, 2.49, 2.5, 2.51), 0.5)
# compare to
round(c(0.5, 1.5, 2.49, 2.5, 2.51))

ceil_at(c(1.45, 2.45, 3.45), 0) # like floor()
ceil_at(c(1.45, 2.45, 3.45, 0.2), "geometric")

Run the code above in your browser using DataLab