Parallel Maximum or Minimum

DESCRIPTION:
Gives the maximum or minimum for each position in a number of vectors.

USAGE:
pmax(..., na.rm=F)
pmin(..., na.rm=F)

REQUIRED ARGUMENTS:
...:
any number of numeric objects.
Missing values (NA) are allowed.

OPTIONAL ARGUMENTS:
na.rm=:
logical flag: should missing values be ignored?

VALUE:
vector whose first element is the maximum (pmax) or minimum (pmin) of the first elements of the arguments, and similarly for the second element, etc. The length of the vector is the length of the longest argument. Shorter vectors are re-used cyclically. If the first argument is longest, then the result will have the attributes of the first argument.

DETAILS:
If an element of any of the arguments is NA, the corresponding element of the result is also NA unless na.rm=TRUE. The maximum or minimum is found of the non-missing values when na.rm=TRUE.

Note the difference between pmax, pmin and max, min. The latter two give the single element which is the maximum or minimum of all the arguments.


SEE ALSO:
max , range , cummax , peaks .

EXAMPLES:
z <- pmax(x, y, 5) # vector as long as larger of x and y
     # where z[i] is max of x[i], y[i], and 5

z <- pmax(x, y, 5, na.rm=T) # as above but missing values are ignored