Returns the (regular or parallel) maxima and minima of the input values. pmax*() and pmin*() take one or more vectors as arguments, recycle them to common length and return a single vector giving the ‘parallel’ maxima (or minima) of the argument vectors.
max(…, na.rm = FALSE)
min(…, na.rm = FALSE)<p></p><p>pmax(…, na.rm = FALSE)
pmin(…, na.rm = FALSE)</p><p>pmax.int(…, na.rm = FALSE)
pmin.int(…, na.rm = FALSE)</p>
| Parameter | Description |
|---|---|
… |
numeric or character arguments (see Note). |
na.rm |
a logical indicating whether missing values should be removed. |
# NOT RUN {
require(stats); require(graphics)
min(5:1, pi) #-> one number
pmin(5:1, pi) #-> 5 numbers
x <- sort(rnorm(100)); cH <- 1.35
pmin(cH, quantile(x)) # no names
pmin(quantile(x), cH) # has names
plot(x, pmin(cH, pmax(-cH, x)), type = "b", main = "Huber's function")
cut01 <- function(x) pmax(pmin(x, 1), 0)
curve( x^2 - 1/4, -1.4, 1.5, col = 2)
curve(cut01(x^2 - 1/4), col = "blue", add = TRUE, n = 500)
## pmax(), pmin() preserve attributes of *first* argument
D <- diag(x = (3:1)/4) ; n0 <- numeric()
stopifnot(identical(D, cut01(D) ),
identical(n0, cut01(n0)),
identical(n0, cut01(NULL)),
identical(n0, pmax(3:1, n0, 2)),
identical(n0, pmax(n0, 4)))
# }