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

