isplit               package:iterators               R Documentation

_S_p_l_i_t _I_t_e_r_a_t_o_r

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

     Returns an iterator that divides the data in the vector 'x' into
     the groups defined by 'f'.

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

     isplit(x, f, drop=FALSE, ...)

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

       x: vector or data frame of values to be split into groups.

       f: a factor or list of factors used to categorize 'x'.

    drop: logical indicating if levels that do not occur should be
          dropped.

     ...: current ignored.

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

     The split iterator.

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

     'split'

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

     x <- rnorm(200)
     f <- factor(sample(1:10, length(x), replace=TRUE))

     it <- isplit(x, f)
     expected <- split(x, f)

     for (i in expected) {
       actual <- nextElem(it)
       stopifnot(actual$value == i)
     }

