Okay thanks to your help I figured it out and stuck the code in a function:

df.sample.exIDs = function(main.df, sample1.df, n, ID1.name, ID2.name) {
  main.ID1.notin.ID2 = main.df[!main.df[,ID1.name] %in%
sample1.df[,ID2.name],]
  sample2.df = main.ID1.notin.ID2[sample(nrow(main.ID1.notin.ID2), size=n),]
  return(sample2.df)
}

Cheers,
Matt Dubins

--
View this message in context: 
http://r.789695.n4.nabble.com/Random-sample-from-a-data-frame-where-ID-column-values-don-t-match-the-values-in-an-ID-column-in-a-se-tp4516448p4518972.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.

Reply via email to