Re: [R] Splitting a data frame with break points where factor changes value

2009-01-31 Thread jim holtman
Here is one approach. You might want to change NAs to 0 if you want them included in the split set.seed(1) x <- sample(c(1, -1), 30, TRUE) x # determine where changes occur change <- cumsum(c(0, diff(x) != 0)) change split(x, change) On Sat, Jan 31, 2009 at 5:25 AM, Titus von der Malsburg wrot

[R] Splitting a data frame with break points where factor changes value

2009-01-31 Thread Titus von der Malsburg
I have a data frame called s3. This data frame has a column called saccade which has two levels 1 and -1. > head(s3$saccade, 100) [1] NA NA NA NA -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 [26] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 [51]