Extremes                package:base                R Documentation

_M_a_x_i_m_a _a_n_d _M_i_n_i_m_a

_D_e_s_c_r_i_p_t_i_o_n:

     Returns the (parallel) maxima and minima of the input values.

_U_s_a_g_e:

     max(..., na.rm=FALSE)
     min(..., na.rm=FALSE)

     pmax(..., na.rm=FALSE)
     pmin(..., na.rm=FALSE)

_A_r_g_u_m_e_n_t_s:

     ...: numeric arguments (see Note).

   na.rm: a logical indicating whether missing values should be
          removed.

_V_a_l_u_e:

     'max' and 'min' return the maximum or minimum of _all_ the  values
     present in their arguments, as 'integer' if all are 'integer',  or
     as 'double' otherwise.

     The minimum and maximum of an empty set are '+Inf' and '-Inf' (in
     this order!) which ensures _transitivity_, e.g., 'min(x1, min(x2))
     == min(x1, x2)'.  From R version 1.5.0, 'max(x) == -Inf' and
     'min(x) == +Inf' whenever 'length(x) == 0' (after removing missing
     values if requested).

     If 'na.rm' is 'FALSE' an 'NA' value in any of the arguments will
     cause a value of 'NA' to be returned, otherwise 'NA' values are
     ignored.

     'pmax' and 'pmin' take several vectors (or matrices) as arguments
     and return a single vector giving the "parallel" maxima (or
     minima) of the vectors.  The first element of the result is the
     maximum (minimum) of the first elements of all the arguments, the
     second element of the result is the maximum (minimum) of the
     second elements of all the arguments and so on.  Shorter vectors
     are recycled if necessary.  If 'na.rm' is 'FALSE', 'NA' values in
     the input vectors will produce 'NA' values in the output.  If
     'na.rm' is 'TRUE', 'NA' values are ignored. 'attributes' (such as
     'names' or 'dim') are transferred from the first argument (if
     applicable).

     'max' and 'min' are generic functions: methods can be defined for
     them individually or via the 'Summary' group generic. For this to
     work properly, the arguments '...' should be unnamed, and dispatch
     is on the first argument.

     By definition the min/max of any vector containing an 'NaN' is
     'NaN', except that the min/max of any vector containing an 'NA' is
     'NA' even if it also contains an 'NaN'.  Note that 'max(NA, Inf)
     == NA' even though the maximum would be 'inf' whatever the missing
     value actually is.

_N_o_t_e:

     'Numeric' arguments are vectors of type integer and numeric, and
     logical (coerced to integer).  For historical reasons, 'NULL' is
     accepted as equivalent to 'integer(0)'.

_R_e_f_e_r_e_n_c_e_s:

     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
     Language_. Wadsworth & Brooks/Cole.

_S_e_e _A_l_s_o:

     'range' (_both_ min and max) and 'which.min' ('which.max') for the
     _arg min_, i.e., the location where an extreme value occurs.

_E_x_a_m_p_l_e_s:

     require(stats)
      min(5:1, pi) #-> one number
     pmin(5:1, pi) #->  5  numbers

     x <- sort(rnorm(100));  cH <- 1.35
     pmin(cH, quantile(x)) # no names
     pmin(quantile(x), cH) # has names
     plot(x, pmin(cH, pmax(-cH, x)), type='b', main= "Huber's function")

