diff                  package:base                  R Documentation

_L_a_g_g_e_d _D_i_f_f_e_r_e_n_c_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     Returns suitably lagged and iterated differences.

_U_s_a_g_e:

     diff(x, ...)
     diff.default(x, lag=1, differences=1)

_A_r_g_u_m_e_n_t_s:

       x: a numeric vector or matrix containing the values to be
          differenced.

     lag: an integer indicating which lag to use.

differences: an integer indicating the order of the difference.

_D_e_t_a_i_l_s:

     `NA''s propagate.

_V_a_l_u_e:

     If `x' is a vector of length `n' and `differences=1', then the
     computed result is equal to the successive differences
     `x[(1:n-lag)] - x[(lag:n)]'. If `difference' is larger than one
     this algorithm is applied recursively to `x'. Note that the
     returned value is a vector which is shorter than `x'.

     If `x' is a matrix then the difference operations are carried out
     on each column separately.

_E_x_a_m_p_l_e_s:

     diff(1:10, 2)
     diff(1:10, 2, 2)

