Present since hutils v1.4.0.
Same as sample, but avoiding the behaviour when
length(x) == 1L.
samp(x, size = length(x), replace = size > length(x), loud = TRUE, prob = NULL)
| x | A vector. |
|---|---|
| size | A non-negative integer, the number of items to return. |
| replace | Should the sampling be done with replacement? Defaults to |
| loud | If |
| prob | As in |
samp(1:5)#> [1] 5 1 2 4 3#> [1] 3 2 5 1 4samp(1:5, size = 10) # no error#>#> [1] 4 3 2 5 2 5 3 4 1 5#> [1] "cannot take a sample larger than the population when 'replace = FALSE'"samp(5, size = 3)#>#>#> [1] 5 5 5#> [1] 1 5 2