sweep                  package: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

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

     Return an array obtained from an input array by sweeping out a
     summary statistic.

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

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

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

       x: an array.

  MARGIN: a vector of indices 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 summary
     statistics swept out.

_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:

     'apply' on which 'sweep' used to be based; 'scale' for centering
     and scaling.

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

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

