Description Usage Arguments Details Value See Also
View source: R/samples_as_matrix.R
Generate a matrix in which each row is a random sample from the set of
the first n
natural numbers.
1 | samples_as_matrix(n, k = n, size = 0, replace = F)
|
n |
integer; defines set to sample from as \{1, …, n\}. |
k |
integer; number of items to draw from the set \{1, …, n\} in each sample (set), also the number of columns in output. |
size |
integer; number of (sample) sets in total, also the number of rows in output. |
replace |
boolean; indicate whether to sample with replacement (within the set). |
This is the author's best effort at efficiently generating a large number of
samples of fixed length (k
) from the set of the first n
natural
numbers without replacement. This implementation samples from the set of all
combinations when n
, k
and size
are favourable,
otherwise it uses a straightforward call to base{sapply}
and
base{sample.int}
.
When sampling with replacement, the implementation is a trivial call to
link{sample.int}
and a matrix constructor.
matrix;
a size
by k
matrix with a random sample from
\{1, …, n\} in each row.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.