Home

pmin

pmin is a function in the R programming language that returns the element-wise minimum across its numeric vector arguments. It computes the pairwise minima for corresponding elements of the input vectors and automatically recycles shorter vectors to a common length.

In use, pmin takes any number of numeric vectors as its arguments and returns a numeric vector

Common usage includes data preparation and vectorized calculations where multiple measurements must be compared element-wise. For

pmin is closely related to pmax, which computes the element-wise maxima. Both functions are part of base

of
the
same
length
as
the
longest
input.
If
an
input
vector
is
shorter
than
others,
it
is
recycled
to
match
the
required
length.
By
default,
pmin
preserves
missing
values,
so
if
any
corresponding
position
contains
NA,
the
result
at
that
position
is
NA.
Setting
na.rm
=
TRUE
ignores
NA
values
when
computing
minima,
provided
at
least
one
non-NA
value
exists
at
that
position.
example,
pmin(1:4,
c(4,3,2,1))
yields
c(1,
3,
2,
1).
When
missing
values
are
present,
na.rm
=
TRUE
can
yield
a
usable
result,
e.g.,
pmin(c(1,
NA,
3),
c(2,
2,
NA),
na.rm
=
TRUE)
results
in
c(1,
2,
3).
R
and
are
commonly
used
alongside
other
min/max
operations,
comparisons,
and
missing-data
handling.
For
readers
using
other
programming
environments,
similar
element-wise
minimum
operations
exist
under
different
names
(for
example,
numpy.minimum
in
Python).
See
also:
pmax,
min,
NA
handling.