I have found that someone else has a similar problem here. But I am very new to programming and to R and I don't understand how I can adapt the answers to my situation. My data looks like what the following code can generate:
df1 = data.frame(ACC1 = sample((1:0), 16, replace = TRUE), RT1 = sample((1000:2000), 16, replace = TRUE))
df2 = data.frame(ACC2 = sample((1:0), 16, replace = TRUE), RT2 = sample((1000:2000), 16, replace = TRUE))
cbind(df1,df2)
Basically I have a number of accuracy variables (ACC) coupled with reaction time (RT) ones. ACC1 corresponds to RT1 and so on. Each row is a single participant. In my real data each participant has done hundreds of trials but in this mock data you can see 2 trials. What I look for is an efficient solution to dynamically pick out the reaction time but only for the trials where the participants gives a correct response (i.e. ACC = 1) and then calculate the mean reaction time of only correct trials. Hope my question is clear and thank you very much in advance for your help.