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:

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

Check this out nerdboinet

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.