clamp: Clamp values to a specified range

View source: R/misc_functions.R

clampR Documentation

Clamp values to a specified range

Description

'clamp' limits the values in a numeric vector 'x' so that all elements are constrained within the interval [a, b]. It dispatches to either 'fclamp' for double precision values or 'fclamp_int' for integer values.

Usage

clamp(x, a = 0, b = 1, inplace = FALSE)

Arguments

x

A numeric vector of values to be clamped.

a

A numeric value specifying the lower bound (default: 0).

b

A numeric value specifying the upper bound (default: 1).

inplace

Logical. If TRUE, the clamping operation is performed in-place; otherwise, a new vector is returned.

Value

A numeric vector with values clamped to the interval [a, b].


ChristK/CKutils documentation built on April 11, 2025, 10:11 p.m.