[R] need help on melt/cast
John Kane
jrkrideau at yahoo.ca
Thu Sep 22 18:28:22 CEST 2011
And I always have a problem with reshape(). Mind you I often have similar problems with melt()
Anyway with the data.frame xx, try
melt(xx, id=c("ID"))
--- On Thu, 9/22/11, Uwe Ligges <ligges at statistik.tu-dortmund.de> wrote:
> From: Uwe Ligges <ligges at statistik.tu-dortmund.de>
> Subject: Re: [R] need help on melt/cast
> To: "Eugene Kanshin" <kanshined1 at gmail.com>
> Cc: r-help at r-project.org
> Received: Thursday, September 22, 2011, 10:30 AM
> I can never remember what melt, cast
> and all that means, hence I simpy
> use reshape() which does not even require any additional
> package:
>
> reshape(dat, direction="long", idvar = "ID",
> varying=list(2:4), v.names="Value",
> times=names(dat)[2:4])
>
> Uwe Ligges
>
>
> On 22.09.2011 15:54, 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.
>
> ______________________________________________
> 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