Calculate a minimum of a pair of vectors

If I have a vector c(1,2,3) and another vector of the same length c(1,4,1) . Is there a way to find the minimum of each pair of numbers in a list pair? that is, to have a function that returns c(1,2,1 ). I do not want to use any application function or cycles, because my vectors will be very large, and the cycle of their passage will take a lot of time.

+6
source share
1 answer

Do you want pmin() :

 > x <- c(1,2,3) > y <- c(1,4,1) > pmin(x,y) [1] 1 2 1 
+7
source

Source: https://habr.com/ru/post/899312/


All Articles