I doubt your data frame looks like that, with all the -, but regardless you can use ifelse() to construct your column.
Sarah On Saturday, December 3, 2011, syrvn <ment...@gmx.net> wrote: > 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. > > ______________________________________________ > R-help@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. > -- Sarah Goslee http://www.stringpage.com http://www.sarahgoslee.com http://www.functionaldiversity.org [[alternative HTML version deleted]] ______________________________________________ R-help@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.