Diag                   package:gnm                   R Documentation

_E_q_u_a_l_i_t_y _o_f _T_w_o _o_r _M_o_r_e _F_a_c_t_o_r_s

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

     Converts two or more factors into a new factor whose value is 0
     where the original factors are not all equal, and nonzero
     otherwise.

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

     Diag(..., binary = FALSE)

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

     ...: One or more factors

  binary: Logical 

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

     Used mainly in regression models for data classified by  two or
     more factors with the same levels.  By default,  operates on
     k-level factors to produce a new factor having k+1 levels; if
     'binary = TRUE' is specified, the result is a coarser binary 
     variable equal to 1 where all of the input factors are equal and 0
      otherwise.

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

     Either a factor (if 'binary = FALSE') or a 0-1 numeric vector (if
     'binary = TRUE').

_A_u_t_h_o_r(_s):

     David Firth

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

     'Symm'

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

     row <- gl(4, 4, 16)
     col <- gl(4, 1, 16)
     diag4by4 <- Diag(row, col)
     matrix(Diag(row, col, binary = TRUE), 4, 4)

