[R] Help with Reshaping from Wide to Long
jlwoodard
john.woodard at wayne.edu
Sat Jul 17 17:42:10 CEST 2010
I am trying to reshape data that are in the wide format into the long format.
The design is a repeated-measures design, which combined 3 levels of shape
(circle, square, triangle) with 3 levels of color (Blue, Red, Green), for a
total of 9 variables. The wide data look like this (sorry I couldn't get
the columns to line up quite right:
Subject CircleBlue CircleRed CircleGreen SquareBlue SquareRed SquareGreen
TriangleBlue TriangleRed TriangleGreen
1 101 95 100 100 95 100 100
60 80 75
2 102 80 90 100 85 90 100
55 45 45
I would like to convert the data to the following format so that I could do
a repeated measures ANOVA:
Accuracy Subject Shape Color
95 subj101 Circle Blue
80 subj102 Circle Blue
100 subj101 Circle Red
90 subj102 Circle Red
100 subj101 Circle Green
100 subj102 Circle Green
95 subj101 Square Blue
85 subj102 Square Blue
100 subj101 Square Red
90 subj102 Square Red
100 subj101 Square Green
100 subj102 Square Green
60 subj101 Triangle Blue
55 subj102 Triangle Blue
80 subj101 Triangle Red
45 subj102 Triangle Red
75 subj101 Triangle Green
45 subj102 Triangle Green
I've been able to accomplish the task using the stack command, together with
some fairly lengthy code to reorganize the stacked data frame. Is it
possible to use the reshape command to accomplish this task in a more
straightforward manner? Many thanks in advance!
John
--
View this message in context: http://r.789695.n4.nabble.com/Help-with-Reshaping-from-Wide-to-Long-tp2292462p2292462.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list