Kcombination | R Documentation |
This function, given a vector of numbers, will return all the possible combinations of a given length k.
Kcombination(data, k, selector)
data |
the vector of numbers (i.e. elements) to consider. |
k |
the length of the returned combination (between 2 and 6 in this version). |
selector |
if set, returns only the combinations containing this number. |
Return a list of all possible combinations for the given vector of numbers.
## Returns the k-combination of the list of numbers: 1,2,3 of length=2.
## i.e. (1,2), (1,3), (2,3)
Kcombination(c(1,2,3),k=2)
## Returns only the k-combination containing the number 1.
## i.e. (1,2), (1,3)
Kcombination(c(1,2,3),k=2,selector=1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.