# How to find pairwise minimum and maximum values from two R vectors

Using two vectors, I want to generate a third vector that should have pairwise maximum values from two vectors. Is there any R function to find the pairwise minimum and maximum from two vectors?

E.g.

a = c(10,1,2,31,41,14,15)

b = c(11,0,5,32,40,12,19)

Result for max = 11  1  5 32 41 14 19

by (31.2k points)

You can use the pmin() function to find the pairwise minimum value in two vectors.

To find the pairwise maximum, you can use the pmax() function.

Example:

> a = c(10,1,2,31,41,14,15)
> b = c(11,0,5,32,40,12,19)
> pmin(a,b)
 10  0  2 31 40 12 15
> pmax(a,b)
 11  1  5 32 41 14 19
{"ft_lang_label":"__label__en","ft_lang_prob":0.84979475,"math_prob":0.9991173,"size":287,"snap":"2021-31-2021-39","text_gpt3_token_len":94,"char_repetition_ratio":0.14840989,"word_repetition_ratio":0.0,"special_character_ratio":0.38675958,"punctuation_ratio":0.20987654,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98346275,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-07-23T18:55:59Z\",\"WARC-Record-ID\":\"<urn:uuid:78a2174d-80ce-4ad0-be67-a8daf6b31b94>\",\"Content-Length\":\"36523\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:53b7e428-7399-48af-ba02-86f69752c5b4>\",\"WARC-Concurrent-To\":\"<urn:uuid:565a9725-704c-4ef3-a11d-d9267568e91f>\",\"WARC-IP-Address\":\"139.64.237.67\",\"WARC-Target-URI\":\"https://www.discoverbits.in/2434/how-find-pairwise-minimum-and-maximum-values-from-two-vectors?show=2436\",\"WARC-Payload-Digest\":\"sha1:ZJWBFEWEUDUB7FIMRFPYLTSDVQFRVDY6\",\"WARC-Block-Digest\":\"sha1:WMGVQ53UCAAHRKXZK3PFWNJU3RH5XFJF\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-31/CC-MAIN-2021-31_segments_1627046150000.59_warc_CC-MAIN-20210723175111-20210723205111-00265.warc.gz\"}"}