?merge should do it. John Kane Kingston ON Canada
> -----Original Message----- > From: lid.z...@gmail.com > Sent: Tue, 7 Jul 2015 09:42:56 -0500 > To: r-help@r-project.org > Subject: [R] add a special column to a matrix > > Hi there, > > I have a two matrices which they have a common column! I want to add the > a > column of second to matrix to the equivalent column of first matrix! > my first matrix is > head(mat1) > a b c d > fg 1:23 dfgv 5 > pt 10:18 tgtgh 1 > wq 15:123 oiljk 6 > fg 9:1323 ass 4 > yr 12:123 kjjlk 5 > > my second matrix: > head(mat2) > e q > 1:23 0 > 10:18 1 > 14:455 2 > 15:123 2 > 9:1323 2 > 12:123 1 > 5:1548 0 > > mat1 and mat2 have a common column (b and e) but is not in the same > order, > I want to add the q column from mat2 to be added to mat1 > my output will be: > > head(mat) > a b c d q > fg 1:23 dfgv 5 0 > pt 10:18 tgtgh 1 1 > wq 15:123 oiljk 6 2 > fg 9:1323 ass 4 2 > yr 12:123 kjjlk 5 1 > > would you please let me know how to do it? > > Thanks > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. ____________________________________________________________ FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop! ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.