% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/freqfuncs.R
\name{jfreq}
\alias{jfreq}
\title{Joint Frequency Distribution of Discrete Variables}
\usage{
jfreq(X, weight = NULL, omitmiss = 1, sort = 0)
}
\arguments{
\item{X}{Input multivariate discrete data}

\item{weight}{weight vector or 1}

\item{omitmiss}{= 0 to return the cartesian product of
unique values of each column of X.}

\item{sort}{= 1 to sort so that the last column changes first. \cr
= 2 to sort by frequency in ascending order \cr
= 3 to sort by frequency in descending order \cr}
}
\value{
A list of: \cr
Xu An object consisting of the (sorted) unique rows of X \cr
f  Assosiated frequency vector
}
\description{
Joint Frequency Distribution of Discrete Variables
}
\details{
Calculates the frequency of the unique rows of X matrix. \cr
Note, however, the order of the rows are different from
the reslt of unique(X) which does not sort the result. \cr
If sort=0, the first column changes first, otherwise, the last
column changes first.
}
\examples{
# numeric varaibles
set.seed(1701)
X <- matrix(sample(0:1,50,replace=1),25)
X <- cbind(X,matrix(sample(1:2,50,replace=1),25))
X <- rbind(X,matrix(c(0,1,0,1),5,4,byrow=1))
colnames(X) <- paste("ccc",1:4,sep="")
res <- jfreq( X )
Print( res$Xu, res$f )

# sort so that the last column changes first
res1 <- jfreq( X, sort=1 )
Print( res1$Xu, res1$f )

# sort by frequency
res1 <- jfreq( X, sort=3 )
Print( res1$Xu, res1$f )

# mixed variable types in a data.frame
Y <- as.data.frame(X)
Y[,2] <- letters[Y[,2]+1]
res2 <- jfreq( Y )
Print( res2$Xu, res2$f )

}
