clip: Clip Values

Description Usage Arguments Value Examples

Description

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

Usage

1
2
3
4
clip(x, .min, .max, ...)

## Default S3 method:
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

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

Example output

Attaching package:ramifyThe following object is masked frompackage:graphics:

    clip

 [1] 3 3 3 4 5 6 7 8 8 8
           [,1]        [,2]       [,3]        [,4]       [,5]
[1,]  0.5989679  0.25046339  1.0000000  0.07318191  1.0000000
[2,] -0.8255741 -0.08805155 -1.0000000 -1.00000000  1.0000000
[3,]  1.0000000  0.21415037 -0.1991875  0.95977401 -0.9345522
[4,]  0.2145139 -0.53433752 -0.8435579 -0.66962534  1.0000000
[5,] -0.3940349 -0.34991819  1.0000000  0.33854212 -0.9484725

ramify documentation built on May 2, 2019, 5:58 a.m.