I'm trying to do some data analysis of a memory experiment. Essentially, participants saw screens where six images - two from one of each of three categories, one of which is faces. They were asked to remember them. Later on, their memory was tested, and the answer was logged as correct or wrong. In all, participants who completed the whole experiment, saw 54 of these screens. For the analysis, I need to code which stimuli were presented in which encoding screen. I have managed to this for one example participant.
Here is the code that I used for the one participant:
beh_data[beh_data$face1!="","screennumber"]=1:54
However, when trying to extend the code, certain participants - who did not manage to complete the whole experiment, and thus did not see all 54 screens - caused a problem. I run into:
Error in [<-.data.frame
(*tmp*
, beh_data$face1 != "", "screennumber", :
missing values are not allowed in subscripted assignments of data frames
How can I adapt this code, so that the 1:54 starts over for every participant is the dataset? Thank you.