[R] need help on melt/cast

Paul Hiemstra paul.hiemstra at knmi.nl
Wed Oct 5 10:11:35 CEST 2011


On 09/22/2011 01:54 PM, Eugene Kanshin wrote:
> Hello,
> I need to convert dataframe from:
>
> ID   T0   T1   T2
> A    1     2     3
> B    4     5     6
> C    7     8     9
>
> to:
>
> ID Variable Value
> A       T0       1
> A       T1       2
> A       T2       3
> B       T0       4
> B       T1       5
> B       T2       6
> C       T0       7
> C       T1       8
> C       T2       9
>
> i tried to use melt cast but it gives me all the time not exactly what I
> need.
> Thank you.
>
> 	[[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.

Hi,

I see you already got your answer, but maybe than for future
questions... You mention, "I tried to use melt and cast" but you do not
provide example code that shows what you tried. This is important for us
to understand where you reasoning about melt and cast goes wrong.
Especially because a simple (as David mentioned):

melt(dat)

got you the right answer.

good luck,
Paul

-- 
Paul Hiemstra, Ph.D.
Global Climate Division
Royal Netherlands Meteorological Institute (KNMI)
Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
P.O. Box 201 | 3730 AE | De Bilt
tel: +31 30 2206 494

http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770



More information about the R-help mailing list