I want to analyze an eye data file in which I need to count fixations within each trial. Here is a sample of my data in which the 3rd and 4rd column are the x and y positions and the 8th column the fixation.
75 1 76498 797 637 0 3.313 3.320 1 0
76 1 76499 793 636 0 3.320 3.321 1 0
77 1 76500 788 637 0 3.292 3.308 1 0
78 1 76501 785 636 0 3.274 3.273 1 0
79 1 76502 781 636 0 3.257 3.265 1 0
80 1 76503 775 637 0 3.257 3.250 1 0
81 1 76504 760 641 0 3.247 3.236 0 0
82 1 76505 746 644 0 3.228 3.258 0
I am trying to create a function that searches every fixation (indicated by a series of ones) until the fixation stops (indicated by a 0 in line82 for example) and then proceeds with the next fixation (the next 1 in column 8). For every trial (second column) I want to have for example 4 fixations each of which outputs the mean(x) and mean(y) and the length (as determined by nrow).
I would be happy if anyone knows a simple way of using a while or for loop since I have a hard time figuring this out. All the best,
Tim