Skip to content

Instantly share code, notes, and snippets.

Created May 3, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/1d24299fecd413038abc to your computer and use it in GitHub Desktop.
Save anonymous/1d24299fecd413038abc to your computer and use it in GitHub Desktop.
dim(popB[[7]])
sampleA<-sample(popA$id,75, replace=FALSE) # mean(popA)=0.7
sampleB<-sample(popB[[7]]$id,75, replace=FALSE) # mean(popB[[7]])=0.7
posNA <- match(sampleA,sampleB)
pos <- posNA[which(posNA!="NA")]
overlap <- sampleB[pos]
sampleB_pure <- sampleB[-pos]
length(sampleB_pure)
pos_popA_2 <- match(sampleA,popA$id)
popB7id <- setdiff(popB[[7]]$id,sampleB)
popB7 <- popB[[7]][popB[[7]]$id %in% popB7id, ]
while (length(sampleB_pure) <75) {
sampleB2<-sample(popB7$id,1)
if (!(sampleB2 %in% sampleA)) {
sampleB_pure <- c(sampleB_pure, sampleB2)
}
popB7id <- setdiff(popB7$id,sampleB2)
popB7 <- popB7[popB7$id %in% popB7id, ]
}
stopifnot(length(intersect(sampleB_pure, sampleA)) == 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment