Skip to content
Prev 5789 / 398506 Next

Selecting a random sample

On Mon, 22 May 2000, Scot W McNary wrote:

            
sample(N, n, replace=F)

Easy?  See ?sample for variations on the theme.

By the way, seq(N)[runif(N) < n/N] would have done it your way in
simpler code, and 

seq(N)[rank(runif(N)) <= n]

is another general solution.