[R] Issues reshaping data

JGull8502 jason.gullifer at gmail.com
Thu Jul 22 00:05:56 CEST 2010


Hello All,

I'm having some trouble reshaping my data from wide to long format. I have
tried using both the reshape function and package. Although I haven't worked
much with the reshape function, I have found the reshape package useful and
intuitive for reshaping data from long to wide format. However, going the
other way has me stumped with this type of data. My data is set up, roughly,
as follows:

SUBJECT  TRIAL    WORD1     WORD1.RT     WORD2     WORD2.RT     ...    
WORD25.RT
1               1        My           100              friend        200             
...             ...
1               2        John's      250              dog           320            
...             ...
1               3        His          120              waiter        400            
...             ...
2               1        My           100              friend        200            
...             ...
2               2        John's      250              dog           320            
...             ...
2               3        His          120              waiter        400            
...             ...

What I would like to do is transform it roughly to:

Subject      TRIAL      WORD    RT    
1                 1          My         100
1                 1          friend     200
....             ....          .....       ....
2                 3          His        120      
2                 3          Waiter     400

The furthest I've gotten with the package is melting the data such that RT
is in its own column by using each WORD#.RT as a measure.var. However, I
can't get the words to go with them (either in the melted frame or trying to
cast the melted data).

I tried the reshape function as well, but kept getting an error about
duplicate row names. I lost the exact code I was using after closing R, but
roughly, I would use Subject as an ID variable, varying =
list(wordRTs,words) [where wordRTs are the set of WORD#.RT and words are the
set of WORD# columns] , v.names=c("RT","WORD").

If anyone has any help, it would be much appreciated!

Thanks,
Jason



-- 
View this message in context: http://r.789695.n4.nabble.com/Issues-reshaping-data-tp2297853p2297853.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list