Sample tuples of elements from a set

Share:

Description

Sample tuples of elements from a set. The elements within a sampled tuple are unique, i.e. no two elements are the same.

Usage

1
2
## Default S3 method:
sampleTuples(x, size, length, ...)

Arguments

x

A set of elements to sample from.

size

The number of tuples to sample.

length

The length of each tuple.

...

Additional arguments passed to sample().

Value

Returns a NxK matrix where N = size and K = length.

Author(s)

Henrik Bengtsson

See Also

sample().

Examples

1
2
3
4
5
6
7
8
9
pairs <- sampleTuples(1:10, size=5, length=2)
print(pairs)

triples <- sampleTuples(1:10, size=5, length=3)
print(triples)

# Allow tuples with repeated elements
quadruples <- sampleTuples(1:3, size=5, length=4, replace=TRUE)
print(quadruples)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.