[R] Maintaining repeated ID numbers when transposing with reshape

jcarmichael jcarmichael314 at gmail.com
Mon Aug 25 23:15:50 CEST 2008


I have a dataset in "long" format that looks something like this:

ID   TEST    RESULT
1       A          17
1       A          12
1       B          15
1       C          12
2       B           8
2       B           9

Now what I would like to do is transpose it like so:

ID    TEST A    TEST B    TEST C
1         17           15          12
1         12            .            .
2          .             8            .
2          .             9            .

When I try:

reshape(mydata, v.names="result", idvar="id",timevar="test",
direction="wide")

It gives me only the first occurrence of each test for each subject.  How
can I transpose my dataset in this way without losing information about
repeated tests?

Any help or guidance would be appreciated!  Thanks!
-- 
View this message in context: http://www.nabble.com/Maintaining-repeated-ID-numbers-when-transposing-with-reshape-tp19151853p19151853.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list