home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Educational / R-0.49-MI / R-0.49-I / help / base / Logic < prev    next >
Encoding:
Text File  |  1997-04-23  |  862 b   |  29 lines

  1.     
  2.     _L_o_g_i_c_a_l _O_p_e_r_a_t_o_r_s
  3.     
  4.          x & y
  5.          x && y
  6.          x | y
  7.          x || y
  8.          ! x
  9.     
  10.     _D_e_s_c_r_i_p_t_i_o_n:
  11.     
  12.          These operators act on logical vectors.  & and && indi-
  13.          cate logical AND and | and || indicate logical OR.  The
  14.          shorter form performs elementwise comparisons in much
  15.          the same way as arithmetic operators.  The longer form
  16.          evaluates left to right examining only the first ele-
  17.          ment of each vector.  Evaluation proceeds only until
  18.          the result is determined.  The longer form is appropri-
  19.          ate for programming control-flow.
  20.     
  21.          ! indicates logical negation (NOT).
  22.     
  23.     _E_x_a_m_p_l_e_s:
  24.     
  25.          y <- 1 +  (x <- rpois(50, lambda=1.5)/4 - 1)
  26.          x[(x > 0) & (x < 1)]    # all x values between 0 and 1
  27.          if(any(x==0) || any(y==0)) "zero encountered"
  28.     
  29.