I am trying to convert a data set that contains a combination of both wide and long data. Currently it looks something like this:
(note: there are many other variables either side, this is just the segment I need to change)
Currently, WTP1 and 2 are in the same row as they are associated with the same participant (buyers). What I need is for there to be one column for WTP so each buyer has two rows which are identical other than the WTP value. Something like this:
WTP
15
5
I have nearly reached a solution using the unite function but the problem is here that the two values are in the same cell rather than in their own rows:
library(dplyr)
long_Data <- unite(mydata.sub1,WTP,player.WTP1:player.WTP2, sep = "_", remove= TRUE)
I'm sure there is an easy solution to this but I'm a beginner! any suggestions welcome. TIA