% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pgm.R
\name{comb}
\alias{comb}
\title{Generate all combinations of n elements taken m at a time.}
\usage{
comb(n, m)
}
\arguments{
\item{n}{total # of elements}

\item{m}{# of elements to choose}
}
\value{
A matrix of the size choose(n,m) x m.
}
\description{
This is very slow when n is large.
}
\details{
This function uses cprod function to calculate combinations. \cr
For example,
 n choose 3 will be calculated as: \cr
 x <- 1:n \cr
 y <- cprod(x,x[-1]) \cr
 y <- y[y[,1]<y[,2],] \cr
 y <- cprod(y,x[-(1:2)]) \cr
 y <- y[y[,2]<y[,3],] \cr
}
\examples{
n <- 5
for( m in 1:n )
 Print( m,choose(n,m), comb(n,m) )

}
