Dear List members,
How can I re-arrange a data frame as detailed below.
old data frame
Item col1 col2 col3 col4
item1 12116 7
item2 108 5 4
item3 3 5 4 3
New data frame
item1 12 11
item1 6 7
item2 108
-boun...@r-project.org] On Behalf Of Peter Solymos
Sent: Friday, June 29, 2012 9:45 AM
To: Manuel Spínola
Cc: r-sig-ecology@r-project.org
Subject: Re: [R-sig-eco] Re-arrange data frame
Manuel,
You haven't specified the general problem, but for this particular situation
this is how you can do it:
x
To: Peter Solymos; Manuel Spínola
Cc: r-sig-ecology@r-project.org
Subject: Re: [R-sig-eco] Re-arrange data frame
Here is an alternative approach that takes a few more steps and assumes the
original data frame is named d0:
# Split into two data frames
d1 - d0[,c(1:3)]
d2 - d0[,c(1,4,5)]
# Rename
-project.org [mailto:
r-sig-ecology-boun...@r-project.org] On Behalf Of Baldwin, Jim -FS
Sent: Friday, June 29, 2012 10:28 AM
To: Peter Solymos; Manuel Spínola
Cc: r-sig-ecology@r-project.org
Subject: Re: [R-sig-eco] Re-arrange data frame
Here is an alternative approach that takes a few more