I have a data frame something like:
                      name         wrist                
nLevel            emot
1                    4094          3.34                    1       
frustrated
2                    4094          3.94                    1       
frustrated
3                    4094            NA                    1       
frustrated
4                    4094          3.51                    1       
frustrated
5                    4094          3.81                    1       
frustrated
6                    4101          2.62                    4          
excited
7                    4094          2.65                    1       
frustrated
8                    4101            NA                    4          
excited
9                    4101          0.24                    4          
excited
10                   4101          0.23                    4          
excited

I am trying to change it to this:

              name          nLevel           emot          w1        
w2       w3      w4      w5     w5
                4094                   1      frustrated    3.34       
3.94      NA    3.51     3.81    2.65
                4101                   4      excited          
2.62       NA     0.24    0.23      NA    NA

The nLevel and emot will never vary with the name, so there can be one  
row per name.  But I need the wrist measurements to be in the same  
row.  The number of wrist measures are variable, so I could fill in  
with NAs .  But I really just need help with reshaping the data frame

I think I had some success with the melt

x 
= 
melt 
.data 
.frame(bsub,id.vars=c("name","nLevel","emot"),measure.vars=c("wrist"))

But I can't figure out the cast to get the wrist values in the rows.


Thanks

ds


David H. Shanabrook
dhsha...@acad.umass.edu
256-1019 (home)




        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to