% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/as.tree.R
\name{as.tree}
\alias{as.tree}
\alias{as.tree.dichotomies}
\alias{as.tree.continuationDichotomies}
\title{Display the Tree Structure of Nested Dichotomies}
\usage{
as.tree(x, ...)

\method{as.tree}{dichotomies}(x, response = NULL, lobstr = FALSE, ...)

\method{as.tree}{continuationDichotomies}(x, response = NULL, lobstr = FALSE, ...)
}
\arguments{
\item{x}{A \code{"dichotomies"} or \code{"continuationDichotomies"} object.}

\item{\dots}{additional arguments (currently unused).}

\item{response}{Optional character string giving the name of the response
variable, used as the root label of the tree. If \code{NULL} (default),
the root is labeled \code{"(response)"}.}

\item{lobstr}{Logical. If \code{FALSE} (default), renders a 2-D ASCII tree
with \code{/} and \code{\\} branch connectors, with each node centered
above its two children. If \code{TRUE}, builds a nested list
representation of the tree and renders it via \code{\link[lobstr]{tree}},
which must be installed.}
}
\value{
Invisibly returns \code{x}; called for its side effect of printing.
}
\description{
Display the nested structure of a \code{"dichotomies"} or
\code{"continuationDichotomies"} object as a 2-D ASCII tree diagram showing
how the response categories are split at each level of the nesting.
}
\details{
The flat list of dichotomies is reconstructed into a binary tree by matching
each dichotomy's domain (the union of its two sides) to the multi-level
groups produced by earlier splits.  Branch labels are taken from the named
arguments to \code{\link{dichotomy}} when present, and are otherwise
generated automatically as \code{\{level1, level2, ...\}}.
}
\examples{
## Womenlf: named group on one branch
comparisons <- logits(work = dichotomy("not.work",
                                       working = c("parttime", "fulltime")),
                      full = dichotomy("parttime", "fulltime"))
as.tree(comparisons, response = "partic")

## GSS: continuation logits for ordered education levels
cont <- continuationLogits(c("<highschool", "highschool",
                             "college", "graduate"))
as.tree(cont, response = "degree")

## gators data: Food choice
# create dichotomies
gators.dichots <- logits(d1=dichotomy("Other", c("Fish", "Invertebrates")),
                         d2=dichotomy("Fish", "Invertebrates"))
as.tree(gators.dichots, response = "Food")
as.tree(gators.dichots, response = "Food", lobstr = TRUE)

}
\seealso{
\code{\link{logits}}, \code{\link{continuationLogits}},
\code{\link{print.dichotomies}}
Other conversions:
\code{\link{as.matrix.dichotomies}}, \code{\link{as.character.dichotomies}}
}
