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(TRUE,TRUE,FALSE,FALSE,TRUE,FALSE,TRUE,TRUE,TRUE)
     rle(z)
     rle(as.character(z))

