# pmax & pmin Functions in R (Example)

This R syntax shows how to compute the parallel maxima and minima with the pmax and pmin functions in the R programming language.

## Example Data

vec1 <- c(4, 7, 1, 5, 10) # Create two numeric vectors vec2 <- c(3, 9, 3, 5, 5) |

vec1 <- c(4, 7, 1, 5, 10) # Create two numeric vectors vec2 <- c(3, 9, 3, 5, 5)

## Parallel Maxima with pmax Function

The pmax function returns the parallel maximum of two input values:

pmax(vec1, vec2) # Apply pmax function # 4 9 3 5 10 |

pmax(vec1, vec2) # Apply pmax function # 4 9 3 5 10

Explanation of the output: 4 is higher than 3, 9 is higher than 7, 3 is higher than 1, both input vectors contain a 5 at the fourth index, and 10 is higher than 5.

## Parallel Minima with pmin Function

The pmin function returns the parallel minimum of two input values:

pmin(vec1, vec2) # Apply pmin function # 3 7 1 5 5 |

pmin(vec1, vec2) # Apply pmin function # 3 7 1 5 5