data.matrix               package:base               R Documentation

_D_a_t_a _F_r_a_m_e _t_o _N_u_m_e_r_i_c _M_a_t_r_i_x

_D_e_s_c_r_i_p_t_i_o_n:

     Return the matrix obtained by converting all the variables in a
     data frame to numeric mode and then binding them together as the
     columns of a matrix.  Factors and ordered factors are replaced by
     their internal codes.

_U_s_a_g_e:

     data.matrix(frame)

_A_r_g_u_m_e_n_t_s:

   frame: a data frame whose components are logical vectors, factors or
          numeric vectors.

_D_e_t_a_i_l_s:

     Supplying a data frame with columns which are not numeric, factor
     or logical is an error.  A warning is given if any non-factor
     column has a class, as then information can be lost.

_V_a_l_u_e:

     If 'frame' is a data frame, a numeric matrix of the same
     dimensions as 'frame', with dimnames taken from the row.names and
     names.

     Otherwise, the result of 'as.matrix'.

_R_e_f_e_r_e_n_c_e_s:

     Chambers, J. M. (1992) _Data for models._ Chapter 3 of
     _Statistical Models in S_ eds J. M. Chambers and T. J. Hastie,
     Wadsworth & Brooks/Cole.

_S_e_e _A_l_s_o:

     'as.matrix', 'data.frame', 'matrix'.

_E_x_a_m_p_l_e_s:

     DF <- data.frame(a=1:3, b=letters[10:12],
                      c=seq(as.Date("2004-01-01"), by = "week", len = 3))
     data.matrix(DF[1:2])
     data.matrix(DF) # gives a warning and quotes dates as #days since 1970.

