swh:1:snp:16c54c84bc54885e783d4424d714e5cc82f479a1
Raw File
Tip revision: b9eecff4551f00d609c3978c3f7bfe0b3fd615a0 authored by Roger Koenker on 18 December 2018, 08:40:03 UTC
version 5.38
Tip revision: b9eecff
combos.Rd
\name{combos}
\alias{combos}
\title{Ordered Combinations}
\description{
All m combinations of the first n integers taken p at a time
are computed and return as an p by m matrix.  The columns
of the matrix are ordered so that adjacent columns differ
by only one element.  This is just a reordered version of
\code{combn} in base R, but the ordering is useful for some
applications.
}
\usage{
combos(n,p)
}
\arguments{
  \item{n}{The n in n choose p}
  \item{p}{The p in n choose p}
}
\value{
  a \code{matrix} of dimension p by \code{choose(n,p)}
} 
\note{
Implementation based on a Pascal algorithm of Limin Xiang 
and Kazuo Ushijima (2001) translated to ratfor for R.
If you have \pkg{rgl} installed you might try \code{demo("combos")}
for a visual impression of how this works.
}
\references{
Limin Xiang and Kazuo Ushijima (2001) 
"On O(1) Time Algorithms for Combinatorial Generation," 
\emph{Computer Journal}, 44(4), 292-302. 
}
\examples{
H <- combos(20,3)
}
\keyword{utilities}
back to top