[R] aggregate over x cases

Jens Bölte boelte at psy.uni-muenster.de
Mon May 11 13:49:38 CEST 2009


Hello,

I have been struggling for quite some time to find a solution for the following problem. I have a data frame which is organized by block and trial. Each trial is represented across several rows in this data frame. I'd like to extract the first x rows per trial and block.

For example
	block	trial	x 	y
1	1	1	605	150
2	1	1	603	148
3	1	1	604	140
4	1	1	600	140
5	1	1	590	135
6	1	1	580	135
7	1	2	607	148
8	1	2	605	152
10	1	2	600	158
.....

Selecting only the the first two rows per trial should result in 

block trial x y 
1	1	605	150
1	1	603	148
1	2	607	148
1	2	605	152

The data I am dealing with a x-y coordinates (samples) from an eye-tracking experiment. I receive the data in this format and need to eliminate unwanted samples.

Thanks Jens Bölte


More information about the R-help mailing list