Learn R Programming

ramify (version 0.3.3)

clip: Clip Values

Description

Clip (i.e., limit) the values in a vector, matrix, or array.

Usage

clip(x, .min, .max, ...)
"clip"(x, .min, .max, ...)

Arguments

x
A vector, matrix, or multi-way array.
.min
.minimum value.
.max
.maximum value.
...
Additional optional arguments.

Value

Returns x with values outside the interval [.min, .max] clipped to the interval edges. That is, values in x smaller than .min become .min, and values larger than .max become .max.

Examples

Run this code
clip(1:10, 3, 8)  # [1] 3 3 3 4 5 6 7 8 8 8
clip(randn(5, 5), .min = -1, .max = 1)

Run the code above in your browser using DataLab