I have the following dataframe (see the link :
). Now, I would like to know whether, for each trial_number, the value in response_time_to_origin is contained between target_onset_plus200 and target_onset_plus1000 but according to multiple conditions :
if 76 <= trial_number <= 151, filter block == 1 and subblock == "A" and then check whether response_time_to_origin is between target_onset_plus200 and target_onset_plus1000. If so answer TRUE, if this happens for other blocks and subblock, answer FALSE.
else if 152 <= trial_number <= 227, filter block == 1 and subblock == "B" and then check whether response_time_to_origin is between target_onset_plus200 and target_onset_plus1000. If so answer TRUE, if this happens for other blocks and subblock, answer FALSE.
ETC.
I have tried to insert the following bit of code, which obviously does not work :
response_accuracy=data_out%>%
select(trial_number, response_time_to_origin)%>%
filter(!is.na(response_time_to_origin))%>%
mutate(list_windows_terminals = list(list_hit_windows))%>%
unnest(list_windows_terminals)%>%
group_by(block, subblock, trial_number)%>%
mutate(response_in_window = if(76 <= trial_number <= 151){
filter(block == 1 & subblock == "A") & response_time_to_origin >
target_onset_plus200 & response_time_to_origin <
target_onset_plus1000)})
Could you help me ? Thanks in advance !