hutilscpp (version 0.10.4)

squish: Squish into a range

Description

Squish into a range

Usage

squish(x, a, b, in_place = FALSE)

Value

A numeric/integer vector with the values of x "squished" between a

and b; values above b

replaced with b and values below a replaced with a.

Arguments

x

A numeric vector.

a, b

Upper and lower bounds

in_place

(logical, default: FALSE) Should the function operate on x in place?

Examples

Run this code
squish(-5:5,-1L, 1L)

Run the code above in your browser using DataLab