sampleTuples: Sample tuples of elements from a set

Description Usage Arguments Value Author(s) See Also Examples

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)

Example output

aroma.light v3.20.0 (2020-10-27) successfully loaded. See ?aroma.light for help.
     [,1] [,2]
[1,]    6    7
[2,]    7   10
[3,]    2    6
[4,]    2    3
[5,]    9    2
     [,1] [,2] [,3]
[1,]   10    2    6
[2,]   10    5    6
[3,]    4    8    5
[4,]    7    6    5
[5,]    5    7    2
     [,1] [,2] [,3] [,4]
[1,]    2    1    1    2
[2,]    3    3    1    3
[3,]    2    1    2    1
[4,]    1    2    3    2
[5,]    3    1    2    1

aroma.light documentation built on Nov. 8, 2020, 4:56 p.m.