In a project, I measured the iodine concentration of tumors (column=ROI_IC) at different off center positions (column=Offcenter) (table heights) in a CT scanner. I know the true concentration of each of the tumors (column=Real_IC; there are 4 different tumors with 4 different real_IC concentrations). Each tumor was measured at each off-center position 10 times (column=Measurement_repeat). I calculated an absolute error between the measured iodine concentration and the real iodine concentration (column=absError_IC)
This is just the head of the data:
Offcenter Measurement_repeat Real_IC ROI_IC absError_IC 1 0 1 0.0 0.4 0.4 2 0 2 0.0 0.3 0.3 3 0 3 0.0 0.3 0.3 4 0 4 0.0 0.0 0.0 5 0 5 0.0 0.0 0.0 6 0 6 0.0 -0.1 0.1 7 0 7 0.0 -0.2 0.2 8 0 8 0.0 -0.2 0.2 9 0 9 0.0 -0.1 0.1 10 0 10 0.0 0.0 0.0 11 0 1 0.4 0.4 0.0 12 0 2 0.4 0.3 0.1 13 0 3 0.4 0.2 0.2 14 0 4 0.4 0.0 0.4 15 0 5 0.4 0.0 0.4 16 0 6 0.4 -0.1 0.5 17 0 7 0.4 0.1 0.3 18 0 8 0.4 0.3 0.1 19 0 9 0.4 0.6 0.2 20 0 10 0.4 0.7 0.3
Now I would like to create a new column called corrError_IC.
In this column, the measured iodine concentration (ROI_IC) should be corrected based on the mean absolute error (mean of 10 measurements) that was found for that specific Real_IC concentration at Offcenter = 0
Because there are 4 tumor concentrations there are 4 mean values at Off-center =0 that I want to apply on the other off-center-values.
mean1=mean of the 10 absError-IC measurements of the `Real_IC=0`
mean2=mean of the 10 absError-IC measurements of the `Real_IC=0.4`
mean3=mean of the 10 absError-IC measurements of the `Real_IC=3`
mean4=mean of the 10 absError-IC measurements of the `Real_IC=5`
Basically, I want the average absolute error for a specific tumor at Offcenter = 0
(there are 4 different tumor types with four different Real_IC) and then I want correct all tumors at the other Offcenter positions by this absolute error values that were derived from the Offcenter = 0
data.
I tried ifelse
statements but I was not able to figure it out.
EDIT: Off-center has specific levels: c(-6,-4,-3,-2,-1,0,1,2,3,4,6)