% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/freqfuncs.R
\name{table2freqdist}
\alias{table2freqdist}
\title{Convert an output of table or xtabs to a simple frequency table format}
\usage{
table2freqdist(tab, omitmiss = 0, index = 1, pat = 2, sort = 1)
}
\arguments{
\item{tab}{An output of native table or xtabs function.}

\item{omitmiss}{= 1 to exclude the zero-freq cells.}

\item{index}{= 0 to output no level indices}

\item{pat}{argument to is.number function.}

\item{sort}{= 0 not to sort the result}
}
\value{
When index == 1 and there are nf factors(variables) to be tabulated, \cr
the output is a matrix or data.frame: \cr
the first nf columns of which consist of the level indices,
and the nf+1st column contains the frequency count. \cr

If the levels are numeric, a matrix will be returned. Otherwise,
a data.frame. \cr
In both cases
  \code{rownames(fd)} contains the combinations of the level names.
}
\description{
Convert an output of table or xtabs to a simple frequency table format
}
\examples{
set.seed(1701)
x <- sample(1:8,10,replace=1); x <- c(x,c(1,1,7)); xc <- paste("x",x,sep="")
y <- sample(0:9,10,replace=1); y <- c(y,c(5,5,0)); yc <- paste("y",y,sep="")
z <- sample(5:9,10,replace=1); z <- c(z,c(5,5,9)); zc <- paste("z",z,sep="")

rest1 <- table( x )
rest2 <- table( x, y )
rest3 <- table( xc,y,z )
restx3 <- xtabs( ~xc+yc+z )

table2freqdist( rest1 )
table2freqdist( rest2 )
table2freqdist( rest3, omitmiss=1 )
table2freqdist( restx3, omitmiss=1, index=0 )

tab2 <- table( x=sample( letters[1:5], 20, replace=1)
             , sample(letters[6:8], 20, replace=1) )
table2freqdist( tab2 )

}
