I am looking for a solution to match 2 dataframes from pairs of values (x and y) as indicated thereafter : First dataframe : DATA1 x y a 1 30 40 0.2 2 21 130 0.3 Second dataframe DATA2 x y b 1 30 40 1 2 40 30 3 3 20 40 7 4 11 30 2 5 130 250 15 6 21 130 17 expected Results : DATA3 x y a b 1 30 40 0.2 1 2 21 130 0.3 17 Many thanks in advance fo your help -- View this message in context: http://www.nabble.com/Matching-pairs-from-two-data-frame-tp16537467p16537467.html Sent from the R help mailing list archive at Nabble.com.
Try: merge(DATA1, DATA2) On Mon, Apr 7, 2008 at 11:20 AM, solea <laffargue_pascal@yahoo.fr> wrote:> > I am looking for a solution to match 2 dataframes from pairs of values (x > and > y) as indicated thereafter : > > First dataframe : > DATA1 > x y a > 1 30 40 0.2 > 2 21 130 0.3 > > Second dataframe > DATA2 > x y b > 1 30 40 1 > 2 40 30 3 > 3 20 40 7 > 4 11 30 2 > 5 130 250 15 > 6 21 130 17 > > expected Results : > > DATA3 > x y a b > 1 30 40 0.2 1 > 2 21 130 0.3 17 > > Many thanks in advance fo your help > > -- > View this message in context: > http://www.nabble.com/Matching-pairs-from-two-data-frame-tp16537467p16537467.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
Try ?merge> d1 <- read.table(textConnection("x y a 1 30 40 0.2 2 21 130 0.3 "))> d2 <- read.table(textConnection("x y b 1 30 40 1 2 40 30 3 3 20 40 7 4 11 30 2 5 130 250 15 6 21 130 17 "))> merge(d1, d2)x y a b 1 21 130 0.3 17 2 30 40 0.2 1 Bill Venables CSIRO Laboratories PO Box 120, Cleveland, 4163 AUSTRALIA Office Phone (email preferred): +61 7 3826 7251 Fax (if absolutely necessary): +61 7 3826 7304 Mobile: +61 4 8819 4402 Home Phone: +61 7 3286 7700 mailto:Bill.Venables at csiro.au http://www.cmis.csiro.au/bill.venables/ -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of solea Sent: Tuesday, 8 April 2008 12:20 AM To: r-help at r-project.org Subject: [R] Matching pairs from two data frame I am looking for a solution to match 2 dataframes from pairs of values (x and y) as indicated thereafter : First dataframe : DATA1 x y a 1 30 40 0.2 2 21 130 0.3 Second dataframe DATA2 x y b 1 30 40 1 2 40 30 3 3 20 40 7 4 11 30 2 5 130 250 15 6 21 130 17 expected Results : DATA3 x y a b 1 30 40 0.2 1 2 21 130 0.3 17 Many thanks in advance fo your help -- View this message in context: http://www.nabble.com/Matching-pairs-from-two-data-frame-tp16537467p1653 7467.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at 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.