I am trying to pivot a very simple table from long format to a wide format.
I am getting these errors for some time now and there must be an easy way to solve it which I am not aware of.
This is fake data about the placebo effect of a medicine on pain perception. I generate it so the ones who expect high pain will report high levels of pain.
Now,
in this case it is very simple to just write the code in a wide manner (either tribble or regular tibble), but this is not very helpful in future case.
The error I get from R looks like they're aware of the difficulties but still is not very helpful:
The error is quite descriptive; the values in "Pain" aren't uniquely identified. There is nothing that means that I=8, N=7, D=3 are related and should be in the same row as each other, same for 9-4-6, same for 10-6-4, etc.
You need another column which can tell pivot wider where to put all of your values. For example:
Thank you. I tried also generating this ID col myself but then ofcourse i had to make 15 ids which didnt help.
That seems like a good solution, I still argue that the previous syntax should have been accepted, as it is the most trivial one. R should be able to recognise which value from 'pain' goes where since in the long format it matches a unique 'Expectation' value.