Description Usage Arguments Details Value Side effects References See Also Examples
Single random selection from the input vector.
1 | safesample(x)
|
x |
a vector. |
This works around the infelicity of the sample
function that
can give the wrong result if x
has length 1.
See Circle 8.2.33 of 'The R Inferno'.
a random element of the input x
.
modify the random seed.
http://www.burns-stat.com/documents/books/the-r-inferno/
1 2 3 4 5 6 | safesample(2:6) # like 'sample(2:6, 1)'
safesample(4) # still works as intended
#compare:
sample(4)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.