

row {base}                                   R Documentation

_R_o_w _I_n_d_e_x_e_s

_U_s_a_g_e_:

     row(x, as.factor=FALSE)

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

       x: a matrix.

as.factor: a logical value indicating whether the value
          should be returned as a factor rather than as
          numeric.

_V_a_l_u_e_:

     An integer matrix with the same dimensions as `x' and
     whose `ij'-th element is equal to `i'.

_S_e_e _A_l_s_o_:

     `col' to get columns.

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

     x <- matrix(1:12, 3, 4)
     # extract the diagonal of a matrix
     dx <- x[row(x)==col(x)]
     dx

     # create an identity 5-by-5 matrix
     x <- matrix(0,nr=5,nc=5)
     x[row(x)==col(x)] <- 1
     x

