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

Titus von der Malsburg malsburg at gmail.com
Sat Jan 31 11:25:41 CET 2009


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]  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
 [76] -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

How can I split this data frame into blocks such that a new block
begins when the value in s3$saccade changes?  Split doesn't seem to work
here.  It's important the solution is efficient because the data frame
is huge.

Thanks!

 Titus




More information about the R-help mailing list