Parallel Minima and Maxima: pmin and pmax

Here are three vectors of the same length, x, y and z. The parallel minimum function, pmin, finds the minimum from any one of the three variables for each subscript, and produces a vector as its result (of length equal to the longest of x, y, or z):

x

[1]     0.99822644     0.98204599     0.20206455     0.65995552     0.93456667     0.18836278

y

[1]     0.51827913     0.30125005     0.41676059     0.53641449     0.07878714     0.49959328

z

[1]     0.26591817     0.13271847     0.44062782     0.65120395     0.03183403     0.36938092

pmin(x,y,z)

[1]     0.26591817     0.13271847     0.20206455     0.53641449     0.03183403     0.18836278

so the first and second minima came from z, the third from x, the fourth from y, the fifth from z, and the sixth from x. The functions min and max produce scalar results.

Get The R Book now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.