Skip to content

Instantly share code, notes, and snippets.

@siscia
Forked from anonymous/gist:1d24299fecd413038abc
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siscia/f8f7267f0cface28e2a1 to your computer and use it in GitHub Desktop.
Save siscia/f8f7267f0cface28e2a1 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
popB7id <- setdiff(popB[[7]]$id, sampleB)
popB7 <- popB[[7]][popB[[7]]$id %in% popB7id, ]
sampleB_pure <- list()
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