Skip to content
Related Articles

Related Articles

Compute the Parallel Minima and Maxima between Vectors in R Programming – pmin() and pmax() Functions
  • Last Updated : 23 Jun, 2020

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)                               

chevron_right


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 :

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)                                                              

chevron_right


Output:

[1] 2 9 5 7 9 8 
My Personal Notes arrow_drop_up
Recommended Articles
Page :