Skip to content

Instantly share code, notes, and snippets.

@gshotwell
Created September 10, 2014 14:47
Show Gist options
  • Save gshotwell/45fed31a1d2bddf05de5 to your computer and use it in GitHub Desktop.
Save gshotwell/45fed31a1d2bddf05de5 to your computer and use it in GitHub Desktop.
Sampling
DF <- data.frame(Pr = runif(100, min = 0, max = 1),
Index = 1:100)
DF$rand<- runif(100, 0, 1)
DF$samp<- 1
DF[ DF$rand > (1- DF$Pr) & DF$rand < DF$Pr, "samp"] <- 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment