Open In App

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

Last Updated : 23 Jun, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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 


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads