Constrain data to a specified range, assigning values from the specified range to those outside the range, typically for graphing purposes.
constrain(x, xrange)
Arguments
x: A numeric vector of values to constrain.
xrange: A numeric vector of length two specifying the constraints, the minimum and maximum value for x.
Returns
A numeric vector, the same length as x, in which the minimum constraint is assigned to values of x less than the minimum, and the maximum constraint is assigned to values of x greater than the maximum.