

sweep {base}                                 R Documentation

_S_w_e_e_p _o_u_t _A_r_r_a_y _S_u_m_m_a_r_i_e_s

_U_s_a_g_e_:

     sweep(x, MARGIN, STATS, FUN="-", ...)

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

       x: an array.

  MARGIN: a giving the extents of `x' which correspond to
          `STATS'.

   STATS: the summary statistic which is to be swept out.

     FUN: the function to be used to carry out the sweep.
          In the case of binary operators such as `"/"'
          etc., the function name must be quoted.

     ...: optional arguments to `FUN'.

_V_a_l_u_e_:

     An array with the same shape as `x', but with the sum-
     mary statistics swept out.

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

     `apply' on which `sweep' is based; `scale' for center-
     ing and scaling.

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

     data(attitude)
     med.att <- apply(attitude, 2, median)
     sweep(data.matrix(attitude), 2, med.att)# subtract the column medians

