I was hoping I could pick your brains as to how to convert my data to long form in R.
I would like to separate out the condition, Chromophore, and source detector from the variable names in my dataframe. Below I pasted a few examples (but there are many more variables in the data frame). So I need to pick out "Angry" and "Happy" and put those into a variable "Condition", then the Chromophores Hbo , HbR , and Hbt , and finally the source detector pairs "1,1", "1,2" (perhaps searching and pulling for the text before and after the comma because I have 49 combinations of these).
Example variable names:
AngryHRFHbO,1,1 AngryHRFHbR,1,1 AngryHRFHbT,1,1 AngryHRFHbO,2,1 AngryHRFHbR,2,1 AngryHRFHbT,2,1 HappyHRFHbO,4,1 HappyHRFHbR,4,1 HappyHRFHbT,4,1 HappyHRFHbO,2,2 HRFHbR,2,2 HappyHRFHbT,2,2
Thank you for your help! I apologize for the formatting. This is my first time posting so I was not sure as to the best way to present the issue.
All the best, Caroline