I assume that you are working in package MatrixCalc. Lets say you have a matrix X. You can call the columns of X this way:
X[,1] for the first column X[,2] for the second column X[,3] for the third column Etc. So lets say that you want to add the first and third column, then you would just do X[,1] + X[,3] If you wanted to call that quantity later on, it might be helpful to give it a name: NewQ <- X[,1] + X[,3] Good luck,Rita On Wed, Jun 22, 2011 at 2:35 AM, 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. > Rita ===================================== "If you think education is expensive, try ignorance."--Derek Bok [[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.