[R] Rearranging the data

From: Vincy Pyne <vincy_pyne_at_yahoo.ca>
Date: Wed, 09 Mar 2011 06:15:11 -0800 (PST)


Dear R helpers,

xx = data.frame(country = c("USA", "UK", "Canada"), x = c(10, 50, 20), y = c(40, 80, 35), z = c(70, 62, 10))

> xx

       country      x     y    z
1      USA        10    40  70
2     

 UK          50   80   62
3     Canada    20   35   10

I need to arrange this as a new data.frame as follows -

country       type     values
USA            x         10 
USA            y         40
USA            z         70
UK             x         50
 
UK             y         80 
UK             z         62  
Canada         x         20  

Canada         y         35
Canada         z         10

I did try reshape package but things are in mess. Please guide

Regards

Vincy  
 

        [[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. Received on Wed 09 Mar 2011 - 14:21:53 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 11 Mar 2011 - 00:30:20 GMT.

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

list of date sections of archive