Open In App

# Compute the Parallel Minima and Maxima between Vectors in R Programming – pmin() and pmax() Functions

`pmin()` function in R Language is used to return the parallel minima of the input vectors.

Syntax: pmin(x1, x2)

Parameters:
x1: vector one
x2: vector two

Example 1:

 `# R program to illustrate``# pmin() function`` ` `# First example vector``x1 <``-` `c(``2``, ``9``, ``5``, ``7``, ``1``, ``8``)  ``  ` `# Second example vector            ``x2 <``-` `c(``0``, ``7``, ``2``, ``3``, ``9``, ``6``)  `` ` `# Application of pmin() in R``pmin(x1, x2)                               `

Output:

`[1] 0  7 2 3 1 6`

#### pmax() Function

`pmax()` function returns the parallel maxima of two or more input vectors.

Syntax: pmax(x1, x2)

Parameters:
x1: vector one
x2: vector two

Example :

 `# R program to illustrate``# pmax() function`` ` `# First example vector``x1 <``-` `c(``2``, ``9``, ``5``, ``7``, ``1``, ``8``)  ``  ` `# Second example vector            ``x2 <``-` `c(``0``, ``7``, ``2``, ``3``, ``9``, ``6``)  `` ` `# Application of pmax() in R``pmax(x1, x2)                                                              `

Output:

`[1] 2 9 5 7 9 8 `