I have a dataframe that look something like this.
| User | V1 | V2 | V3 |
|---|---|---|---|
| Jim | .34 | .33 | .88 |
| David | .54 | .34 | .71 |
| Scott | .12 | .25 | .12 |
| Frank | .76 | .76 | .44 |
| Doug | .68 | .09 | .54 |
| Tom | .91 | .67 | .92 |
But I would like to calculate a new variables. I want the new variables (V1_DISTfromMEAN, V2_DISTfromMEAN, V3_DISTfromMEAN) to be calculated by subtracting each observation from their corresponding variables (V1, V2, V3) from the column's mean value. For example, the mean for the column V1 is .55. So for Jim, I would want the equation to be .34 - .55 = -0.21. for V1_DISTfromMean. The resulting dataframe would look something like the one below, with all values filled in.
| User | V1 | V2 | V3 | V1_DISTfromMEAN | V2_DISTfromMEAN | V1_DISTfromMEAN |
|---|---|---|---|---|---|---|
| Jim | .34 | .33 | .88 | - .21 | ??? | ??? |
| David | .54 | .34 | .71 | - .01 | ??? | ??? |
| Scott | .12 | .25 | .12 | ??? | ??? | ??? |
| Frank | .76 | .76 | .44 | ??? | ??? | ??? |
| Doug | .68 | .09 | .54 | ??? | ??? | ??? |
| Tom | .91 | .67 | .92 | ??? | ??? | ??? |
Any help would be greatly appreciated.Let me know if I've failed to include all the necessary data.