Description Usage Arguments Details Value Author(s) References Examples
Generate all combinations of the elements of x taken m at a time. If x is a positive integer, returns all combinations of the elements of seq(x) taken m at a time. If argument "fun" is not null, applies a function given by the argument to each point. If simplify is FALSE, returns a list; else returns a vector or an array. "..." are passed unchanged to function given by argument fun, if any.
combn2:Generate all combinations of the elements of x taken two at a time. If x is missing, generate all combinations of 1:n taken two at a time (that is, the indices of x that would give all combinations of the elements of x if x with length n had been given). Exactly one of arguments "x" and "n" should be given; no provisions for function evaluation.
nCm: Compute the binomial coefficient ("n choose m"), where n is any real number and m is any integer. Arguments n and m may be vectors; they will be replicated as necessary to have the same length. Argument tol controls rounding of results to integers. If the difference between a value and its nearest integer is less than tol, the value returned will be rounded to its nearest integer. To turn off rounding, use tol = 0. Values of tol greater than the default should be used only with great caution, unless you are certain only integer values should be returned.
1 |
x |
vector source for combinations |
m |
number of elements |
fun |
function to be applied to each combination (may be null) |
simplify |
logical, if FALSE, returns a list, otherwise returns vector or array |
... |
args to fun |
Nijenhuis, A. and Wilf, H.S. (1978) Combinatorial Algorithms for Computers and Calculators. NY: Academic Press.
see simplify argument
Code by Scott Chasalow, R package and doc prep by Vince Carey, stvjc@channing.harvard.edu
~put references to the literature/web site here ~
1 2 3 4 5 6 7 | combn(letters[1:4], 2)
combn(10, 5, min) # minimum value in each combination
# Different way of encoding points:
combn(c(1,1,1,1,2,2,2,3,3,4), 3, tabulate, nbins = 4)
#Compute support points and (scaled) probabilities for a
#Multivariate-Hypergeometric(n = 3, N = c(4,3,2,1)) p.f.:
# table.mat(t(combn(c(1,1,1,1,2,2,2,3,3,4), 3, tabulate,nbins=4)))
|
Attaching package: 'combinat'
The following object is masked from 'package:utils':
combn
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] "a" "a" "a" "b" "b" "c"
[2,] "b" "c" "d" "c" "d" "d"
[1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[38] 1 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 2 2 2 2 2 2 2 2 2 1
[2,] 1 1 0 0 0 1 1 1 0 0 0 2
[3,] 0 0 1 1 0 0 0 0 1 1 0 0
[4,] 0 0 0 0 1 0 0 0 0 0 1 0
[,51] [,52] [,53] [,54] [,55] [,56] [,57] [,58] [,59] [,60] [,61] [,62]
[1,] 1 1 1 1 1 1 1 1 1 1 1 1
[2,] 2 1 1 1 2 1 1 1 1 1 1 0
[3,] 0 1 1 0 0 1 1 0 1 1 0 2
[4,] 0 0 0 1 0 0 0 1 0 0 1 0
[,63] [,64] [,65] [,66] [,67] [,68] [,69] [,70] [,71] [,72] [,73] [,74]
[1,] 1 1 2 2 2 2 2 2 1 1 1 1
[2,] 0 0 1 1 1 0 0 0 2 2 1 1
[3,] 1 1 0 0 0 1 1 0 0 0 1 1
[4,] 1 1 0 0 0 0 0 1 0 0 0 0
[,75] [,76] [,77] [,78] [,79] [,80] [,81] [,82] [,83] [,84] [,85] [,86]
[1,] 1 1 1 1 1 1 1 1 1 1 1 1
[2,] 1 2 1 1 1 1 1 1 0 0 0 2
[3,] 0 0 1 1 0 1 1 0 2 1 1 0
[4,] 1 0 0 0 1 0 0 1 0 1 1 0
[,87] [,88] [,89] [,90] [,91] [,92] [,93] [,94] [,95] [,96] [,97] [,98]
[1,] 1 1 1 1 1 1 1 1 1 1 1 1
[2,] 2 1 1 1 2 1 1 1 1 1 1 0
[3,] 0 1 1 0 0 1 1 0 1 1 0 2
[4,] 0 0 0 1 0 0 0 1 0 0 1 0
[,99] [,100] [,101] [,102] [,103] [,104] [,105] [,106] [,107] [,108]
[1,] 1 1 0 0 0 0 0 0 0 0
[2,] 0 0 3 2 2 2 2 2 2 1
[3,] 1 1 0 1 1 0 1 1 0 2
[4,] 1 1 0 0 0 1 0 0 1 0
[,109] [,110] [,111] [,112] [,113] [,114] [,115] [,116] [,117] [,118]
[1,] 0 0 0 0 0 0 0 0 0 0
[2,] 1 1 2 2 2 1 1 1 1 1
[3,] 1 1 1 1 0 2 1 1 2 1
[4,] 1 1 0 0 1 0 1 1 0 1
[,119] [,120]
[1,] 0 0
[2,] 1 0
[3,] 1 2
[4,] 1 1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.