 # Calculations based on conditionals using mutate?

Hello,

I want to compute reaction time 1 (RT1) and reaction time 2 (RT2) dependent on two conditions.
Using mutate/case_when from the dplyr package.

For instance:

If ((stim_order=0) &(response_order=0)) RT1=(key_DT_resp1.rt *1000)+100.
if ((stim_order=0) &(response_order=0)) RT2=(key_DT_resp2.rt *1000)+(key_DT_resp1.rt *1000)-100.

So based on the variables stim_order and response_order the calculation for RT1 and RT2 changes respectively.

In the following I just tried it for stim_order==0 && response_order==0 - for RT1

``````mydata2_cleaned <- mutate(mydata2_cleaned, RT1 = ((key_DT_resp1.rt*1000)+100) , case_when(stim_order==0) & (response_order==0))

Case 1 (`stim_order == 0`) must be a two-sided formula, not a logical vector.
i Input `..2` is `case_when(stim_order == 0) & (response_order == 0)`.

mydata2_cleaned <- mutate(mydata2_cleaned, case_when(stim_order==0 & response_order==0, RT1 = ((key_DT_resp1.rt*1000)+100)))

x Case 1 (`stim_order == 0 & response_order == 0`) must be a two-sided formula, not a logical vector.
i Input `..1` is `case_when(...)`.

``````

Is the mutate/case_when function suitable for this operation, or should I use a different approach?
Any help would be appreciated.