Hi: Based on the information you provided, I would suggest looking into the transform() and within() functions in base R, and perhaps the mutate() function in package plyr.
HTH, Dennis On Tue, Jun 21, 2011 at 11:35 PM, Nabila Binte Zahur <nab...@nus.edu.sg> wrote: > Dear Sirs/Madam, > > I am a beginner to R, and I am currently working on a data matrix which looks > like this: > >> head(oligo) > > ko:K00001 ko:K00003 ko:K00005 ko:K00008 ko:K00009 ko:K00010 ko:K00012 > AAA 370 631 365 67 > 164 455 491 > KAA 603 1208 170 157 68 > 495 922 > NAA 60 110 10 7 > 44 51 94 > DAA 183 802 41 62 26 > 166 263 > CAA 58 12 58 1 > 1 23 8 > TAA 451 468 201 90 131 > 320 518 > > > For certain specific columns, I need to merge the columns in such a way that > the elements get added together. > > For example, in order to merge the first and the second columns, my output > for the first row shld be > > ko:K00001/ko:K00003 > AAA 1001 (i.e. 370+631) > KAA 1811 (i.e. 603+1208) > > > and so on for the whole column. > > A colleague suggested using rowsum, but that seems to add up all the rows for > ALL the columns and not just specified ones. Also, the output doesnt contain > the column or row headers. > > Could you please suggest a solution? > > Yours sincerely > Nabila Binte Zahur > > ______________________________________________ > 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. > ______________________________________________ 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.