Currently I have data in this "wide" format:
|Participant|Banana|Apple|Orange|
|-|-|-|-|
|P1|0|0|0|
|P2|1|1|1|
|P3|0|0|0|
Ideally, I want to convert these data to long format for mixed models, i.e.,
|Participant|Item|Accuracy|
|-|-|-|
|P1|Banana|0|
|P1|Apple|0|
|P1|Orange|0|
|P2|Banana|1|
|P2|Apple|1|
|P2|Orange|1|
|P3|Banana|0|
|P3|Apple|0|
|P3|Orange|0|
(for some reason my tables are breaking, sorry folks.)
Code to reproduce
dat <- data_frame(
Participant = paste0("P", 1:3),
Banana = sample(0:1, 3, TRUE),
Apple = sample(0:1, 3, TRUE),
Orange = sample(0:1, 3, TRUE),
)
Been combing through a few posts and there are bits and pieces of the answer around but I can't quite put it together re: extracting and splicing the participants and transposing their rows.
Thanks for any help.