Is this what you want:
my.df - data.frame(a = c(1:5, 1:10, 1:20), b = runif(35))
split(my.df, c(0, cumsum(diff(my.df$a) 0)))
$`0`
a b
1 1 0.2655087
2 2 0.3721239
3 3 0.5728534
4 4 0.9082078
5 5 0.2016819
$`1`
a b
6 1 0.89838968
7 2 0.94467527
8 3 0.66079779
9 4
Hi all,
Given a data frame:
my.df - data.frame(a = c(1:5, 1:10, 1:20), b = runif(35))
I want to split it by a such that I end up with a list containing 3
components i.e. the first containing a = 1 to 5, the second a = 1 to 10 etc.
In other words, sets of sequences of a.
I can't seem to find
2 matches
Mail list logo