Thanks a lot to Steve Lianoglou and Peter Savicky for their help! Alfredo
-----Messaggio originale----- Da: Steve Lianoglou [mailto:mailinglist.honey...@gmail.com] > I'd to match-merge 2 tables in such a manner that I keep all the rows in > table 1, but not the rows that are in both table 1 and 2. >> master <- data.frame(ID=2001:2011) >> train <- data.frame(ID=2004:2006) >> valid <- ??? > in this example table valid should have the following >> str(valid) > Year: int 2001 2002 2003 2007 2008 2009 2010 2011 Are you working with only one column at a time? If so: keep <- !(master$ID %in% train$ID) valid <- master[keep,] -----Messaggio originale----- Da: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Per conto di Petr Savicky Try the following, which assumes that "train" is a subset of "master". master <- data.frame(ID=2001:2011) train <- data.frame(ID=2004:2006) valid <- master[! (master[, 1] %in% train[ ,1]), , drop=FALSE] ______________________________________________ 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.