Arithmetic               package:base               R Documentation

_A_r_i_t_h_m_e_t_i_c _O_p_e_r_a_t_o_r_s

_D_e_s_c_r_i_p_t_i_o_n:

     These binary operators perform arithmetic on numeric or complex
     vectors (or objects which can be coerced to them).

_U_s_a_g_e:

     x + y
     x - y
     x * y
     x / y
     x ^ y
     x %% y
     x %/% y

_A_r_g_u_m_e_n_t_s:

    x, y: numeric or complex vectors or objects which can be coerced to
          such, or other objects for which methods have been written.

_D_e_t_a_i_l_s:

     The binary arithmetic operators are generic functions: methods can
     be written for them individually or via the 'Ops') group generic
     function.

     If applied to arrays the result will be an array if this is
     sensible (for example it will not if the recycling rule has been
     invoked).

     Logical vectors will be coerced to numeric vectors, 'FALSE' having
     value 0 and 'TRUE' having value one.

     '1 ^ y' and 'y ^ 0' are '1', _always_. 'x ^ y' should also give
     the proper "limit" result when either argument is infinite (i.e.,
     '+- Inf').

     Objects such as arrays or time-series can be operated on this way
     provided they are conformable.

     For real arguments, '%%' can be subject to catastrophic loss of
     accuracy if 'x' is much larger than 'y', and a warning is given if
     this is detected.

_V_a_l_u_e:

     They return numeric vectors containing the result of the element
     by element operations.  The elements of shorter vectors are
     recycled as necessary (with a 'warning' when they are recycled
     only _fractionally_).  The operators are '+' for addition, '-' for
     subtraction, '*' for multiplication, '/' for division and '^' for
     exponentiation.

     '%%' indicates 'x mod y' and '%/%' indicates integer division.  It
     is guaranteed that 'x == (x %% y) + y * ( x %/% y )' (up to
     rounding error) unless 'y == 0' where the result is 'NA' or 'NaN'
     (depending on the 'typeof' of the arguments).

_R_e_f_e_r_e_n_c_e_s:

     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
     Language_. Wadsworth & Brooks/Cole.

_S_e_e _A_l_s_o:

     'sqrt' for miscellaneous and 'Special' for special mathematical
     functions.

     'Syntax' for operator precedence.

_E_x_a_m_p_l_e_s:

     x <- -1:12
     x + 1
     2 * x + 3
     x %% 2 #-- is periodic
     x %/% 5

