last                 package:sfsmisc                 R Documentation

_G_e_t _L_a_s_t _E_l_e_m_e_n_t_s _o_f _a _V_e_c_t_o_r

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

     Extract the last elements of a vector.

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

     last(x, length.out = 1, na.rm = FALSE)

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

       x: any vector.

length.out: integer indicating how many element are desired.  If
          positive, return the 'length.out' last elements of 'x'; if
          negative, the last 'length.out' elements are _dropped_. 

   na.rm: logical indicating if the last non-missing value (if any)
          shall be returned.  By default (it is 'FALSE' and) the last
          elements (whatever its values) are returned.

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

     a vector of length 'abs(length.out)' of _last_ values from 'x'.

_N_o_t_e:

     This function may eventually be deprecated for the new (R 1.9.0)
     function 'tail()'.

     Useful for the 'turnogram()' function in package 'pastecs'.

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

     Werner Stahel (stahel@stat.math.ethz.ch), and independently,
     Philippe Grosjean (phgrosjean@sciviews.org), Frdric Ibanez
     (ibanez@obs-vlfr.fr).

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

     'first', 'turnogram'

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

     a <- c(NA, 1, 2, NA, 3, 4, NA)
     last(a)
     last(a, na.rm=TRUE)

     last(a, length = 2)
     last(a, length = -3)

