powered by
Present since hutils v1.4.0. Same as sample, but avoiding the behaviour when length(x) == 1L.
hutils v1.4.0
sample
length(x) == 1L
samp(x, size = length(x), replace = size > length(x), loud = TRUE, prob = NULL)
A vector.
A non-negative integer, the number of items to return.
Should the sampling be done with replacement? Defaults to TRUE if size > length(x), with a message.
TRUE
size > length(x)
If TRUE, the default, any behaviour known to be different from sample is flagged with a message.
As in sample.
# NOT RUN { samp(1:5) sample(1:5) samp(1:5, size = 10) # no error tryCatch(sample(1:5, size = 10), error = function(e) print(e$m)) samp(5, size = 3) sample(5, size = 3) # }
Run the code above in your browser using DataLab