rle                   package:base                   R Documentation

_R_u_n _L_e_n_g_t_h _E_n_c_o_d_i_n_g

_D_e_s_c_r_i_p_t_i_o_n:

     Compute the lengths and values of runs of equal values in a
     vector.

_U_s_a_g_e:

     rle(x)

_A_r_g_u_m_e_n_t_s:

       x: a (numerical, logical or character) vector.

_V_a_l_u_e:

     A list with components 

 lengths: a vector containing the length of each run.

  values: a vector of the same length as `lengths' with the
          corresponding values.

_E_x_a_m_p_l_e_s:

     x <- rev(rep(6:10, 1:5))
     rle(x)
     ## $lengths
     ## [1] 5 4 3 2 1
     ## $values
     ## [1] 10  9  8  7  6
     z <- c(T,T,F,F,T,F,T,T,T)
     rle(z)
     rle(as.character(z))

