[R] Reshape
    Toby Gass 
    tobygass at warnercnr.colostate.edu
       
    Tue Sep 28 04:31:26 CEST 2010
    
    
  
Hello, helpeRs, 
I've been trying, unsuccessfully, to change a dataframe from long to 
wide format using reshape (the original).  I would appreciate it if 
someone could demonstrate the correct syntax.  The script below will 
create a toy example.  The new wide data should have a column name 
for each unique entry in the "fame" column.   Under each column 
should be either the appropriate weight or na, if there is no match.  
Thus, the end product should have column names:
valley  plot   trt   18w   16iso  12:0, etc.
Here is the toy script for the starting data in long form:
dat <- data.frame(fame =  gl(4,1,10, labels = c( "18w", "16iso", 
"12:0", "16w")), valley = gl(2,6,10, labels = c("H", "M")), plot = 
gl(5, 2, 10), trt = gl(2,1,10, labels = c("e", "g")), weight = 
1000*runif(10, 0, 1))
Thank you for your assistance.
Toby
    
    
More information about the R-help
mailing list