matrix                 package:base                 R Documentation

_M_a_t_r_i_c_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     `matrix' creates a matrix from the given set of values.

     `as.matrix' attempts to turn its argument into a matrix.

     `is.matrix' tests if its argument is a (strict) matrix.

_U_s_a_g_e:

     matrix(data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL)
     as.matrix(x)
     is.matrix(x)

_A_r_g_u_m_e_n_t_s:

    data: an optional data vector.

    nrow: the desired number of rows

    ncol: the desired number of columns

   byrow: logical. If `FALSE' (the default) the matrix is filled by
          columns, otherwise the matrix is filled by rows.

dimnames: A `dimnames' attribute for the matrix: a `list' of length 2.

       x: an R object.

_D_e_t_a_i_l_s:

     If either of `nrow' or `ncol' is not given, an attempt is made to
     infer it from the length of `data' and the other parameter.

     `is.matrix' returns `TRUE' if `x' is a matrix (i.e., it not a
     `data.frame' and has a `dim' attribute of length 2) and `FALSE'
     otherwise.

_S_e_e _A_l_s_o:

     `data.matrix'.

_E_x_a_m_p_l_e_s:

     is.matrix(as.matrix(1:10))
     data(warpbreaks)
     !is.matrix(warpbreaks)# data.frame, NOT matrix!
     str(warpbreaks)
     str(as.matrix(warpbreaks))#using as.matrix.data.frame(.) method

