[R] How to arrange the data

Alain Guillet alain.guillet at uclouvain.be
Fri Dec 17 10:59:59 CET 2010


Hi,

You can use the reshape package and the melt function :

melt(data, id="date")

Alain


On 17-Dec-10 10:40, 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
>
>
> I have presented here a small part of large data. I tried to convert the data into matrix, then transpose etc. but things are not working for me. Please guide
>
> Thanking in advance
>
> Amy Milano
>
>
>   
>
>
>
>
> 	[[alternative HTML version deleted]]
>
>
>
> ______________________________________________
> R-help at 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.

-- 
Alain Guillet
Statistician and Computer Scientist

SMCS - IMMAQ - Université catholique de Louvain
http://www.uclouvain.be/smcs

Bureau c.316
Voie du Roman Pays, 20
B-1348 Louvain-la-Neuve
Belgium

tel: +32 10 47 30 50



More information about the R-help mailing list