[R] How to arrange the data
    Gerrit Eichner 
    Gerrit.Eichner at math.uni-giessen.de
       
    Fri Dec 17 10:51:35 CET 2010
    
    
  
Hello, Amy,
take a look at
?reshape
In your case, I think,
reshape( yourdatafame, varying = c( "value1", "value2", "value3"),
          v.name = "amount", times = c( "value1", "value2", "value3"),
          timevar = "name", direction = "long")
should work.
Hth -- Gerrit
On Fri, 17 Dec 2010, Amy Milano wrote:
> Dear R helpers
>
> I have one data as given below.
>
> date                     value1          value2             value3
> 30-Nov-2010           100                 40                 61
> 25-Nov-2010           108                 31                 88
> 14-Sep-2010            11                 180               56
>
> I want the following output
>
> date                 name       amount
> 30-Nov-2010      value1        100
> 30-Nov-2010      value2         40
> 30-Nov-2010      value3         61
> 25-Nov-2010      value1       108
> 25-Nov-2010      value2         31
> 25-Nov-2010      value3         88 
> 14-Sep-2010      value1        11
> 14-Sep-2010      value2      180
> 14-Sep-2010      value3      56
> ...
    
    
More information about the R-help
mailing list