I have a data frame which looks like following and it continues up to subject 22 Beta is the dependent measure.
Subject ROI Block Condition Beta
1 motor1 1 nopred_noom -2.8653
1 motor1 1 pred_noom -2.9126
1 motor1 1 nopred_om -2.8688
1 motor1 1 pred_om -2.9098
1 motor1 1 null -2.7717
1 motor1 2 nopred_noom -2.2382
1 motor1 2 pred_noom -2.0583
1 motor1 2 nopred_om -2.2207
1 motor1 2 pred_om -2.1928
1 motor1 2 null -2.1166
1 motor1 3 nopred_noom -1.5992
1 motor1 3 pred_noom -1.5493
1 motor1 3 nopred_om -1.5230
1 motor1 3 pred_om -1.4851
1 motor1 3 null -1.5624
2 motor1 1 nopred_noom -1.1354
2 motor1 1 pred_noom -1.1614
2 motor1 1 nopred_om -1.2779
2 motor1 1 pred_om -1.1234
2 motor1 1 null -1.2203
2 motor1 2 nopred_noom -1.5728
2 motor1 2 pred_noom -1.6614
2 motor1 2 nopred_om -1.7076
2 motor1 2 pred_om -1.7702
2 motor1 2 null -1.4170
There are 5 conditions, but I want to use the condition null as the baseline and want to subtract it from other conditions in each corresponding block and subject.
so I would subtract Beta in subject 1, block 1, condition "null" from Beta measures in other conditions in subject1, block 1 but then I want to use beta value "null" from subject1, block2 for measures in subject 1, block2 and so on.
null condition occurs every 5 conditions and i suspect I need to use a loop but I am quite new to R and I am not sure how to do this.
any help is appreciated!!! thanks :)