bound: Set a Minimum or a Maximum or Both to a Vector.

Description Usage Arguments Value Note Author(s) See Also Examples

View source: R/bound.R

Description

The function lbound sets a minimum to the elements of a vector, ubound a maximum and bound both.

Usage

1
2
3
lbound(x, m)
ubound(x, M)
bound(x, m, M)

Arguments

x

double, vector to put in [m, M].

m

double, the minimum.

M

double, the maximum.

Value

A vector with the values of x on which all values lower that m has been replaced by m and all values greater than M has been replace by M.

Note

x <- lbound(x, a) replaces x <- x*(x >= a) + a*(x < a) and x[x < a] <- a in a much faster way.

Author(s)

Nicolas Baradel - PGM Solutions

See Also

http://pgm-solutions.com/packages

Examples

1
2
3
K <- 1
x <- rpgm.rnorm(12, 0.5)
lbound(x-K, 0)

rpgm documentation built on March 18, 2018, 2:24 p.m.