Learn R Programming

pracma (version 0.2-2)

combs, randcomb: Generate Combinations

Description

Generates all combinations of length m of a vector a.

Usage

combs(a, m)
randcomb(a, m)

Arguments

a
numeric vector of some length n
m
integer with 0 <= m="" <="n

Value

  • matrix representing combunations of the elements of a

Details

combs generates combinations of length n of the elements of the vector a.

randcomb generates just one random combination.

See Also

perms, randperm

Examples

Run this code
combs(seq(2, 10, by=2), m = 3)
randcomb(seq(2, 10, by=2), m = 3)

Run the code above in your browser using DataLab