Dear mailing list, may some one be kind to help me solve following problem. I am trying to write a code that will combine two tables "x" and "y". The first columns of both tables are unique identification for the rows. The first column of table "X" is a sub set of the first column of "Y". I need to find the matching rows in both tables by looking on their unique identification at the first columns. Table is "X" is (19010 rw, 6 col) and "Y" is (19850 rw, 9 col). Therefore my out put need to be "Z" is (19010rw,15 col). A small example of my input and out put is here below. Thank you in advance! input Table"X"" A,1,2,2 B,2,1,1 C,1,2,2 E,2,2,1 F,2,1,1 H,1,2,2 J,2,1,1 K,2,1,1 Table"Y" A,GG,CG, B,CC,TC, C,CA,AA, D,AT,TT, E,AA,AA, F,CG,CG, G,CC,CC, H,GG,GT, I,GT,TT, J,AA,AT, K,AC,CC, output Table"Z"" A,1,2,2,A,GG,CG, B,2,1,1,B,CC,TC, C,1,2,2,C,CA,AA, E,2,2,1,E,AA,AA, F,2,1,1,F,CG,CG, H,1,2,2,H,GG,GT, J,2,1,1,J,AA,AT, K,2,1,1,K,AC,CC, Regards Hannes [[alternative HTML version deleted]]
On Sat, Jun 17, 2006 at 02:40:47PM +0100, yohannes alazar wrote:> Dear mailing list, may some one be kind to help me solve following problem. > > I am trying to write a code that will combine two tables "x" and "y". The > first columns of both tables are unique identification for the rows. The > first column of table "X" is a sub set of the first column of "Y". I need to > find the matching rows in both tables by looking on their unique > identification at the first columns.?merge cu Philipp -- Dr. Philipp Pagel Tel. +49-8161-71 2131 Dept. of Genome Oriented Bioinformatics Fax. +49-8161-71 2186 Technical University of Munich Science Center Weihenstephan 85350 Freising, Germany and Institute for Bioinformatics / MIPS Tel. +49-89-3187 3675 GSF - National Research Center Fax. +49-89-3187 3585 for Environment and Health Ingolst?dter Landstrasse 1 85764 Neuherberg, Germany http://mips.gsf.de/staff/pagel
Hi Change V1 for the name of the column to be matched on X and Y cbind(X,Y[match(X$V1,Y$V1),]) Neurorox>From: "yohannes alazar" <hannesalazar at gmail.com> >To: r-help at stat.math.ethz.ch >Subject: [R] managing data >Date: Sat, 17 Jun 2006 14:40:47 +0100 > >Dear mailing list, may some one be kind to help me solve following problem. > >I am trying to write a code that will combine two tables "x" and "y". The >first columns of both tables are unique identification for the rows. The >first column of table "X" is a sub set of the first column of "Y". I need >to >find the matching rows in both tables by looking on their unique >identification at the first columns. Table is "X" is (19010 rw, 6 col) and >"Y" is (19850 rw, 9 col). Therefore my out put need to be "Z" is >(19010rw,15 >col). A small example of my input and out put is here below. > > >Thank you in advance! > > >input >Table"X"" > >A,1,2,2 >B,2,1,1 >C,1,2,2 >E,2,2,1 >F,2,1,1 >H,1,2,2 >J,2,1,1 >K,2,1,1 > >Table"Y" > >A,GG,CG, >B,CC,TC, >C,CA,AA, >D,AT,TT, >E,AA,AA, >F,CG,CG, >G,CC,CC, >H,GG,GT, >I,GT,TT, >J,AA,AT, >K,AC,CC, > >output >Table"Z"" > >A,1,2,2,A,GG,CG, >B,2,1,1,B,CC,TC, >C,1,2,2,C,CA,AA, >E,2,2,1,E,AA,AA, >F,2,1,1,F,CG,CG, >H,1,2,2,H,GG,GT, >J,2,1,1,J,AA,AT, >K,2,1,1,K,AC,CC, > > Regards Hannes > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! >http://www.R-project.org/posting-guide.html