sample_safe takes a sample of the specified size from the elements of x using either with or without replacement.

sample_safe(x, size, replace = FALSE)

Arguments

x

a vector of one or more elements from which to choose

size

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

replace

should sampling be with replacement?

Details

Works like base::sample(), but it is safer if x is a scalar.