which.min                package:base                R Documentation

_W_h_e_r_e _i_s _t_h_e _M_i_n() _o_r _M_a_x() ?

_D_e_s_c_r_i_p_t_i_o_n:

     Determines the location, i.e., index of the (first) minimum or
     maximum of a numeric vector.

_U_s_a_g_e:

     which.min(x)
     which.max(x)

_A_r_g_u_m_e_n_t_s:

       x: numeric vector, whose 'min' or 'max' is searched.

_V_a_l_u_e:

     an 'integer' of length 1 or 0 (iff 'x' has no non-'NA's) , giving
     the index of the _first_ minimum or maximum respectively of 'x'.

     If this extremum is unique (or empty), the result is the same (but
     more efficient) as  'which(x == min(x))' or 'which(x == max(x))'
     respectively.

_A_u_t_h_o_r(_s):

     Martin Maechler

_S_e_e _A_l_s_o:

     'which', 'max.col', 'max', etc.

     'which.is.max' in package 'nnet' differs in breaking ties at
     random (and having a "fuzz" in the definition of ties).

_E_x_a_m_p_l_e_s:

     x <- c(1:4,0:5,11)
     which.min(x)
     which.max(x)

     data(presidents)
     presidents[1:30]
     range(presidents, na.rm = TRUE)
     which.min(presidents)# 28
     which.max(presidents)# 2

