[R] Odp: How to arrange the data
Petr PIKAL
petr.pikal at precheza.cz
Fri Dec 17 11:04:15 CET 2010
Hi
use melt from reshape package
> test<-data.frame(a=letters[1:3], v1=1:3, v2=5:7, v3=100:102)
> test
a v1 v2 v3
1 a 1 5 100
2 b 2 6 101
3 c 3 7 102
> melt(test)
Using a as id variables
a variable value
1 a v1 1
2 b v1 2
3 c v1 3
4 a v2 5
5 b v2 6
6 c v2 7
7 a v3 100
8 b v3 101
9 c v3 102
Regards
Petr
r-help-bounces at r-project.org napsal dne 17.12.2010 10:40:14:
> 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.
More information about the R-help
mailing list