=========
--- On Wed, 3/9/11, Vincy Pyne wrote:
> From: Vincy Pyne
> Subject: [R] Rearranging the data
> To: r-help@r-project.org
> Received: Wednesday, March 9, 2011, 9:15 AM
> Dear R helpers,
>
> xx = data.frame(country = c("USA&qu
Try this:
reshape(xx, direction = "long", varying = list(2:4), idvar = "country")
On Wed, Mar 9, 2011 at 11:15 AM, Vincy Pyne wrote:
> 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
reshape2 Like this?
> require(reshape2)
Loading required package: reshape2
> melt(xx)
Using country as id variables
country variable value
1 USAx10
2 UKx50
3 Canadax20
4 USAy40
5 UKy80
6 Canaday35
7 U
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
4 matches
Mail list logo