Page 1 of 1

Structure of choice-data

Posted: 13 Apr 2022, 07:28
by JuliavB
Dear all,

unfortunately, my choice data (incl. design) so far is organized like this, representing one choice (so I have it in three rows instead of one row per choice set as described in the apollo manual):
Resp_ID, Task, Alternative1, Attr1, Attr2, Attr3, Choice made (0 or 1)
Resp_ID, Task, Alternative2, Attr1, Attr2, Attr3, Choice made (0 or 1)
Resp_ID, Task, Alternative3, Attr1, Attr2, Attr3, Choice made (0 or 1)

Is there a way that apollo can also read and use the data in this format or even a script that reshapes the data to the required form?
Any help is highly appreciated, as my request is quite urgent.

Thank you very much in advance.
Best,
J.

Re: Structure of choice-data

Posted: 15 Apr 2022, 11:10
by stephanehess
Hi

this is in long format rather than wide format. You'll have to reshape the data. We don't have a function for doing this automatically as it very much depends on the data you have. However, we could produce such a function for future versions. If you want to encourage that development, then you could share your data with me offline and I'll see what I can do for you

Stephane

Re: Structure of choice-data

Posted: 15 Apr 2022, 17:43
by JuliavB
Hi Stephane,

thank you for your reply.
I just managed to reshape my data with the tidyr package and pivot_wider function which worked out pretty well. Maybe that is also interesting for other users ;)

Best,
J.

Re: Structure of choice-data

Posted: 15 Apr 2022, 18:00
by stephanehess
Great

feel free to post your code (or part of it) here to inspire others

Stephane

Re: Structure of choice-data

Posted: 17 Apr 2022, 17:02
by JuliavB
Please find below the part of my code which I´ve used to reshape my data from long to wide format:

library(tidyr)
Daten_Choice_Pivot <- pivot_wider(Daten_Choice_Design[,-7], names_from = Concept,
values_from = c("Attr1", "Attr2", "Attr3"))

Daten_Choice_Design <- Daten_Choice_Design[which(Daten_Choice_Design$Response==1),]
Daten_Choice_Pivot$Choice <- Daten_Choice_Design$Concept

Re: Structure of choice-data

Posted: 17 Apr 2022, 17:25
by stephanehess
Thanks. I've written a function that will be included in Apollo 0.2.8 that allows the user to reshape the data very easily from long to wide format (though not using tidyr)

Re: Structure of choice-data

Posted: 17 Apr 2022, 18:03
by JuliavB
That sounds great, thank you very much!