I have these two dataframes in which 'id' is the key field> tabellaid nome 1 1 PIEMONTE 2 2 VALLED'AOSTA 3 3 LOMBARDIA 4 4 TRENTINO 5 5 VENETO 6 6 FRIULI AND> tabid nome 1 1 PIEMONTE 2 2 VALLED'AOSTA 3 3 LOMBARDIA 4 4 TRENTINO 5 25 CAMPANIA 6 28 LAZIO Is there any R-one-command able to select the only rows of tab that are not present in tabella, matching the two tables on 'id'? The result should be 5 25 CAMPANIA 6 28 LAZIO I was able to obtain this results by means of the merge command merging the two tables and selecting according to the <NA> fields, therefore in two steps.... Ciao Vittorio
That's something for the %in% command. Try this (untested!) tab[(tab$id %in% tabella$id) == FALSE, ] Cheers, Thierry ------------------------------------------------------------------------ ---- ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 Thierry.Onkelinx op inbo.be www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -----Oorspronkelijk bericht----- Van: r-help-bounces op stat.math.ethz.ch [mailto:r-help-bounces op stat.math.ethz.ch] Namens Vittorio Verzonden: woensdag 7 februari 2007 14:24 Aan: r-help op stat.math.ethz.ch Onderwerp: [R] Finding not-matching rows in tables I have these two dataframes in which 'id' is the key field> tabellaid nome 1 1 PIEMONTE 2 2 VALLED'AOSTA 3 3 LOMBARDIA 4 4 TRENTINO 5 5 VENETO 6 6 FRIULI AND> tabid nome 1 1 PIEMONTE 2 2 VALLED'AOSTA 3 3 LOMBARDIA 4 4 TRENTINO 5 25 CAMPANIA 6 28 LAZIO Is there any R-one-command able to select the only rows of tab that are not present in tabella, matching the two tables on 'id'? The result should be 5 25 CAMPANIA 6 28 LAZIO I was able to obtain this results by means of the merge command merging the two tables and selecting according to the <NA> fields, therefore in two steps.... Ciao Vittorio ______________________________________________ R-help op 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 and provide commented, minimal, self-contained, reproducible code.
Hi you can use %in% tabella[tabella$x %in% tab$x,] to select rows which are in both and tabella[!(tabella$x %in% tab$x),] to select only non matching ones HTH Petr On 7 Feb 2007 at 0:00, Vittorio wrote: Date sent: Wed, 7 Feb 2007 14:23:45 +0100 (GMT+01:00) From: Vittorio <vdemart1 at tin.it> To: r-help at stat.math.ethz.ch Subject: [R] Finding not-matching rows in tables Send reply to: Vittorio <vdemart1 at tin.it> <mailto:r-help-request at stat.math.ethz.ch?subject=unsubscribe> <mailto:r-help-request at stat.math.ethz.ch?subject=subscribe>> I have these two dataframes in which 'id' is the key field > > tabella > > id nome > 1 1 PIEMONTE > 2 2 VALLED'AOSTA > 3 3 > LOMBARDIA > 4 4 TRENTINO > 5 5 VENETO > 6 6 FRIULI > > AND > > > tab > id nome > 1 1 PIEMONTE > 2 2 VALLED'AOSTA > 3 3 LOMBARDIA > 4 4 TRENTINO > 5 25 CAMPANIA > 6 28 > LAZIO > > Is there any R-one-command able to select the only rows of tab > that are not present in tabella, matching the two tables on 'id'? The > result should be > > 5 25 CAMPANIA > 6 28 LAZIO > > I was able to > obtain this results by means of the merge command merging the two > tables and selecting according to the <NA> fields, therefore in two > steps.... > > Ciao > Vittorio > > ______________________________________________ > 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 and provide commented, > minimal, self-contained, reproducible code.Petr Pikal petr.pikal at precheza.cz