MINI MINI MANI MO
%
% Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
%
\name{ore.crosstab}
\alias{ore.crosstab}
\title{Oracle R Enterprise Crosstabulations}
\description{
Expands on function \code{\link[stats]{xtabs}} by supporting multiple
columns with optional aggregations, weighting, and ordering options.
Building cross-tabulation is a pre-requisite to using the function
\code{\link{ore.freq}}.
}
\usage{
ore.crosstab(expr, data, ..., group.by = NULL, order = NULL,
weights = NULL, where = NULL, strata = NULL)
}
\arguments{
\item{expr}{A formula object defining a cross-tabulation.
Syntax: \code{[CS] ~ CS [*<WC>][/<GC>][^[SC][|OC]} where \code{CS}
is \code{[+CSET][+CRANGE]}, \code{CSET} is \code{[+CSET]}, and
\code{CRANGE} is \code{<FROM COLUMN>-<TO COLUMN>}.}
\item{data}{An \code{\link[OREbase:ore.frame-class]{ore.frame}} object.}
\item{\dots}{Additional arguments.}
\item{group.by}{An optional character vector specifying the group by
column names within argument \code{data}.}
\item{order}{An optional character string specifying an ordering for
the cross-tabulation; one of \code{"NAME"} (ascending by name),
\code{"-NAME"} (descending by name), \code{"DATA"} (ascending by
data), \code{"-DATA"} (descending by data), \code{"FREQ"} (ascending
by frequency), \code{"-FREQ"} (descending by frequency),
\code{"INTERNAL"}.}
\item{weights}{An optional character string specifying a numeric column
within argument \code{data} to use as analytic weights.}
\item{where}{An optional character vector specifying arbitrary
partitions of argument \code{data}.}
\item{strata}{An optional character string specifying a column within
argument \code{data} to use as stratification variable.}
}
\value{
When argument \code{where} is not specified, returns an
\code{\link[OREbase:ore.frame-class]{ore.frame}} object.
When argument \code{where} is specified, returns a list of
\code{\link[OREbase:ore.frame-class]{ore.frame}} objects.
}
\references{
\href{http://www.oracle.com/technetwork/database/database-technologies/r/r-enterprise/documentation/index.html}{Oracle R Enterprise}
}
\author{
Oracle \email{oracle-r-enterprise@oracle.com}
}
\seealso{
\code{\link{ore.freq}},
\code{\link[stats]{xtabs}}
}
\examples{
IRIS <- ore.push(iris)
table(iris$Species, iris$Petal.Length)
ore.crosstab(Species ~ Petal.Length, data = IRIS)
# 1 way table
ore.crosstab(~Species, data = IRIS)
# 2 2-way tables
ore.crosstab(Species ~ Petal.Length + Sepal.Length, data = IRIS)
# Order rows of cross-tabulation by asc frequency counts
ore.crosstab(Species ~ Petal.Length | FREQ, data = IRIS)
# Order by descending frequency counts
ore.crosstab(Species ~ Petal.Length | -FREQ, data = IRIS)
# As many cross-tabs as distinct values in Species
ore.crosstab(Petal.Length ~ Sepal.Length / Species, data = IRIS)
# Syntactic simplication
ore.crosstab(Sepal.Length - Petal.Width ~ Species, data = IRIS)
# Illustration of the use of group.by
ore.crosstab(Species ~ Petal.Length, data = IRIS)
# Compare with the following where Petal.Length values are hidden
ore.crosstab(~ Species, group.by = "Petal.Length", data = IRIS)
# Use of derived columns
IRIS$PetalBins <- ifelse(IRIS$Petal.Length < 2, "SMALL",
ifelse(IRIS$Petal.Length < 5, "MEDIUM", "LARGE"))
ore.crosstab(Species ~ PetalBins, data = IRIS)
}
\keyword{category}
OHA YOOOO