Logic                  package:base                  R Documentation

_L_o_g_i_c_a_l _O_p_e_r_a_t_o_r_s

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

     These operators act on logical vectors.

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

     ! x
     x & y
     x && y
     x | y
     x || y
     xor(x, y)

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

     `!' indicates logical negation (NOT).

     `&' and `&&' indicate logical AND and `|' and `||' indicate
     logical OR.  The shorter form performs elementwise comparisons in
     much the same way as arithmetic operators.  The longer form
     evaluates left to right examining only the first element of each
     vector.  Evaluation proceeds only until the result is determined. 
     The longer form is appropriate for programming control-flow.

     `xor' indicates elementwise exclusive OR.

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

     `TRUE' or `logical'.

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

     y <- 1 + (x <- rpois(50, lambda=1.5) / 4 - 1)
     x[(x > 0) & (x < 1)]    # all x values between 0 and 1
     if (any(x == 0) || any(y == 0)) "zero encountered"

