sample.vec: Samples n elements from vector x even if x is size 1...

Description Usage Arguments

View source: R/sample.vec.R

Description

Samples n elements from vector x even if x is size 1 (https://stackoverflow.com/questions/13990125/sample-from-vector-of-varying-length-including-1)

Usage

1

Arguments

x

vector to sample from

size

a non-negative integer giving the number of items to choose.

replace

should sampling be with replacement? (default=FALSE)

prob

a vector of probability weights for obtaining the elements of the vector being sampled.

useHash

logical indicating if the hash-version of the algorithm should be used. Can only be used for replace = FALSE, prob = NULL, and size <= n/2, and really should be used for large n, as useHash=FALSE will use memory proportional to n.


vanderlindenma/lindenutils documentation built on Dec. 23, 2021, 2:10 p.m.