r - How do I use plyr to number rows? -


Actually I want an autoincremented id column based on my cohorts - in this situation. (Km, cvcit)

  & gt; MyDataFrame Size Kimar cvCut cumsum 1 8132 23 10 8132 10000 778 23 10 13789274 30000 324 23 10 23658740 50000 182 23 10 28534840 100000 65 23 10 33943283 200000 25 23 10 37954383 250000 584 23 12 16546507 300000 110 23 12 29435303 400000 28 23 12 34697860 600000 127 23 2 47124443 600001 127 23 2 47124570  

I need a column which is the new line names based on Kimmer / Seawwat group

  & gt; MyDataFrame Size Kimar cvCut cumsum newID 1 8132 23 10 8132 1 10000 778 23 10 13789274 2 30000 324 23 10 23658740 3 50000 182 23 10 28534840 4 100000 65 23 10 33943283 5 200000 25 23 10 37954383 6 250000 584 23 12 16546507 1 300000 110 23 12 29435303 2 400000 28 23 12 34697860 3 600000 127 23 2 47124443 1 600001 127 23 2 47124570 2  

I will do it like this:

  Library (plyr) ddply (df, c (" kmer "," cvcut "), changing, newID = seq_along (kmer))  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -