fwd.combn | R Documentation |
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. Optional arguments ...
are passed unchanged to the function given by argument fun
, if any.
fwd.combn(x, m, fun = NULL, simplify = TRUE, ...)
fwd.nCm(n, m, tol = 1e-08)
x |
a vector or a single value. |
n |
a positive integer. |
m |
a positive integer. |
fun |
a function to be applied to each combination. |
simplify |
logical, if |
tol |
optional, tolerance value. |
... |
optional arguments passed to |
Returns a vector or an array if simplify = TRUE
, otherwise a list.
Renamed by Kjell Konis for inclusion in the Forward Library 11/2002
Scott Chasalow
Nijenhuis, A. and Wilf, H.S. (1978) Combinatorial Computers and Calculators. NY: Academic Press.
fwd.combn(letters[1:4], 2)
fwd.combn(10, 5, min) # minimum value in each combination
# Different way of encoding points:
fwd.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(t(fwd.combn(c(1,1,1,1,2,2,2,3,3,4), 3, tabulate, nbins=4)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.