[R] Data alignment

syrvn mentor_ at gmx.net
Sat Dec 3 12:43:26 CET 2011


Hello!

I have a data.frame which looks like:

Name - Value
A - 400
A - 300
B - 200
B - 350
C - 500
C - 350
D - 450 
D - 600
E - 700 
E - 750
F - 630
F - 650

I want to add another column where all A,B should get an index 1, all C,D an
index of 2 and all E,F an index of 3 so that the data.frame looks like:

ID - Name - Value
1 - A - 400
1 - A - 300
1 - B - 200
1 - B - 350
2 - C - 500
2 - C - 350
2 - D - 450 
2 - D - 600
3 - E - 700 
3 - E - 750
3 - F - 630
3 - F - 650

My data.frame is quite big so I cannot add all values by hand.


Cheers




--
View this message in context: http://r.789695.n4.nabble.com/Data-alignment-tp4153024p4153024.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list