[R] selectively altering variable value
Jens Bölte
boelte at psy.uni-muenster.de
Mon Aug 3 17:05:46 CEST 2009
Hello,
I have run an eye-tracking experiment for which I now like to analyse the saccades. Participants looked from a fixation cross (ia = 5) to the target area (ia = 4) in following example of a data frame. ia = 9 stands for everything else. A saccade is indicated by saccade = 1. Sometimes the saccade just ends before the target area (see below). This is due to the parameters that determine a saccade and a fixation and some measurement error (accuracy of the eyetracker). I like to include the first two no-saccades in a target area into the saccade. The simplest approach, at least to my knowledge, would be to replace the value saccade = 0 with saccade = 1 for the first two ia = 4 (see the example below). But that is beyond my rather limited knowledge in R.
My data frame is structured as follows (.... stands for multiple rows; just deleted for presentation purposes)
vp trial ia saccade (other columns deleted for presentation purposes)
1 1 5 0
1 1 5 0
1 1 5 0
1 1 5 1
1 1 5 1
....
1 1 9 1
1 1 9 1
1 1 9 1
....
1 1 4 1
1 1 4 0
.....
1 2 5 0
1 2 5 0
1 2 5 0
1 2 5 1
1 2 5 1
....
1 2 9 1
1 2 9 1
1 2 9 1
....
1 2 4 1
1 2 4 1
1 2 4 0
1 2 4 0
aso. more trials follow (up 72).
1 3 5 0
1 3 5 0
1 3 5 0
1 3 5 1
1 3 5 1
....
1 3 9 1
1 3 9 1
1 3 9 1
....
1 3 4 0 <- how do I get -> 1 3 4 1
1 3 4 0 <- how do I get -> 1 3 4 1
1 3 4 0 <- how do I keep -> 1 3 4 0
.....
1 4 5 0
1 4 5 0
1 4 5 0
1 4 5 1
1 4 5 1
....
1 4 9 1
1 4 9 1
1 4 9 1
....
1 4 4 0 <- how do I get -> 1 4 4 1
1 4 4 0 <- how do I get -> 1 4 4 1
1 4 4 0 <- how do I keep -> 1 4 4 0
1 4 4 0 <- how do I keep -> 1 4 4 0
1 4 4 0
1 4 4 0
1 4 4 0
Thanks a lot for any help
Jens
More information about the R-help
mailing list