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, nc=2)
     (centered.x <- scale(x, scale=FALSE))
     cov(centered.scaled.x <- scale(x))# all 1

