Description Usage Arguments Value Note Author(s) See Also Examples
Use this function to generate a reproducible random
sample. Random samples are usually made reproducible by
setting a numeric seed with set.seed
. This
function does some transformations to a given
alphanumeric string before compting a seed and drawing a
sample based on that seed.
1 | TDASample(inString, N, n)
|
inString |
The alphanumeric string that you want to use for generating your seed |
N |
The total population you are sampling from |
n |
The number of samples you need |
Returns a list
with the class
TDASample
to handle the formatting of the output.
The list items include:
Metadata
A
character vector of length = 4 containing the date the
sample was drawn, the input string that was used, the
population size, and the desired sample size.
SeedUsed
The seed that was automatically generated
by the function.
FinalSample
The final
result of running set.seed(SeedUsed);
sample(--input parameters--)
FinalSample_sorted
As above, but sorted
The inString
argument is not
case-sensitive, but it is "space-sensitive". That is to
say, inString = "Ananda Mahto"
will result in the
same seed as inString = "ananda mahto"
, but a
different seed from inString = "anandamahto"
or
inString = " Ananda Mahto "
(note the extra
spaces before and after the names).
For a more robust conversion from alphanumeric strings to
seeds before sampling, the
stringseed.sampling
function from the "mrdwabmisc" package is recommended.
Ananda Mahto
sample
, set.seed
,
stringseed.sampling
1 2 3 4 5 6 7 8 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.