Quick optimized equivalent to sample(x,size,replace=TRUE)
quick_sample(x, size)
x | a vector |
---|---|
size | number of elements to sample |
sample of size "size" taken from x
quick_sample(1:20,5)#> [1] 12 15 19 16 6# microbenchmark::microbenchmark( # runif = {(1:20)[ceiling(runif(5,0,20))]}, # quick_sample = quick_sample(1:20,5), # sample = sample(1:20,5,replace = TRUE), # times = 1000,control = list("warmup"=100) # )