scale                  package:base                  R Documentation

_S_c_a_l_i_n_g _a_n_d _C_e_n_t_e_r_i_n_g _o_f _M_a_t_r_i_x-_l_i_k_e _O_b_j_e_c_t_s

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

     'scale' is generic function whose default method centers and/or
     scales the columns of a numeric matrix.

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

     scale(x, center = TRUE, scale = TRUE)

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

       x: a numeric matrix(like object).

  center: either a logical value or a numeric vector of length equal to
          the number of columns of 'x'.

   scale: either a logical value or a numeric vector of length equal to
          the number of columns of 'x'.

_D_e_t_a_i_l_s:

     The value of 'center' determines how column centering is
     performed. If 'center' is a numeric vector with length equal to
     the number of columns of 'x', then each column of 'x' has the
     corresponding value from 'center' subtracted from it. If 'center'
     is 'TRUE' then centering is done by subtracting the column means
     (omitting 'NA's) of 'x' from their corresponding columns, and if
     'center' is 'FALSE', no centering is done.

     The value of 'scale' determines how column scaling is performed
     (after centering). If 'scale' is a numeric vector with length
     equal to the number of columns of 'x', then each column of 'x' is
     divided by the corresponding value from 'scale'. If 'scale' is
     'TRUE' then scaling is done by dividing the (centered) columns of
     'x' by their root-mean-square, and if 'scale' is 'FALSE', no
     scaling is done.

     The root-mean-square for a column is obtained by computing the
     square-root of the sum-of-squares of the non-missing values in the
     column divided by the number of non-missing values minus one.

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

     For 'scale.default', the centered, scaled matrix. The numeric
     centering and scalings used (if any) are returned as attributes
     '"scaled:center"' and '"scaled:scale"'

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

     'sweep' which allows centering (and scaling) with arbitrary
     statistics.

     For working with the scale of a plot, see 'par'.

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

     require(stats)
     x <- matrix(1:10, ncol=2)
     (centered.x <- scale(x, scale=FALSE))
     cov(centered.scaled.x <- scale(x))# all 1

