From: Gabor Grothendieck <ggrothendieck_at_gmail.com>

Date: Tue 16 May 2006 - 14:15:44 EST

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue May 16 14:21:41 2006

Date: Tue 16 May 2006 - 14:15:44 EST

Try melt from the reshape package:

library(reshape)

melt(DF, 1:2)

You may may need to resort it if the order is important.

On 5/15/06, YIHSU CHEN <yschen@jhu.edu> wrote:

> Dear R folks:

*>
**> I wonder anyone has a elegent way of doing what I need to do.
**>
**> I have a data frame called with four columns: V1, V2, A1 and A2:
**>
**> V1 V2 A1 A2
**> A B 1.2 2.0
**> A D 1.2 4.0
**> A C 2.4 2.2
**>
**> What I need to do is to convert it into the following data frame with a new column x, where x is just the stacked up of A1 and A2 placed with respective V1 and V2 in the first two columns:
**>
**> V1 V2 x
**> A B 1.2
**> A B 2.0
**> A D 1.2
**> A D 4.0
**> A C 2.4
**> A C 2.2
**>
**> I wonder whether there is an efficient way to do it since I have huge dataset.
**>
**> Thank you very much
**>
**> Yihsu
**>
**>
**>
**>
**>
**>
**>
**>
**>
**>
**>
**>
**>
**>
**>
**>
**>
**>
**>
**>
**>
**> Yihsu Chen
**> The Johns Hopkins University
**>
**> ______________________________________________
**> R-help@stat.math.ethz.ch mailing list
**> https://stat.ethz.ch/mailman/listinfo/r-help
**> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
**>
*

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue May 16 14:21:41 2006

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.1.8, at Tue 16 May 2006 - 16:10:14 EST.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*