% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/upsetplot.R
\name{prepare_upset_data}
\alias{prepare_upset_data}
\title{Prepare data for an UpSet plot}
\usage{
prepare_upset_data(
  data,
  in_form = "auto",
  group_by = NULL,
  group_by_sep = "_",
  id_by = NULL,
  specific = TRUE
)
}
\arguments{
\item{data}{A data frame, a named list of element vectors, or an
\code{UpsetPlotData} object.}

\item{in_form}{A character string specifying the input format.  One of
\code{"auto"} (default; detect from \code{data} structure),
\code{"long"}, \code{"wide"}, \code{"list"}, or \code{"upset"}.}

\item{group_by}{A character vector of column name(s) defining the sets.
In long format, this is the column with set labels.  In wide format,
these are the set-membership columns.  When \code{NULL} in wide format,
all columns except \code{id_by} are used.  Ignored for list and upset
inputs.}

\item{group_by_sep}{A character string to concatenate multiple
\code{group_by} columns when \code{in_form = "long"}.  Default: \code{"_"}.}

\item{id_by}{A character string specifying the column name for instance
identifiers.  Required for long format; optional for wide format (a
synthetic \code{.id} column is created if omitted).}

\item{specific}{A logical value.  When \code{TRUE} (default), only specific
intersections are returned (elements belonging exclusively to the shown
set combination).  When \code{FALSE}, all overlapping items are included.
See \url{https://github.com/gaospecial/ggVennDiagram/issues/64}.}
}
\value{
An \code{UpsetPlotData} object --- a data frame with an
\code{Intersection} list-column of set labels and one row per element.
A \code{"group_order"} attribute preserves the original set order.
}
\description{
Converts raw input (long data frame, wide data frame, named list, or an
existing \code{UpsetPlotData} object) into the internal format expected by
\code{\link{UpsetPlotAtomic}()}.  This is the data-preparation workhorse
that handles all input format parsing.
}
\section{Input formats}{


\strong{Long format} --- one row per (set, element) pair:
\preformatted{
group_by id_by
A        a1
A        a2
B        a1
B        a3
}
Requires both \code{group_by} and \code{id_by}.

\strong{Wide format} --- each row is an element, each set has a logical or
0/1 membership column:
\preformatted{
A      B
TRUE   TRUE
TRUE   FALSE
FALSE  TRUE
}
The set columns are identified by \code{group_by} (or all columns except
\code{id_by} when \code{group_by = NULL}).

\strong{List format} --- a named list of element vectors:
\preformatted{
list(A = c("a1", "a2"), B = c("a1", "a3"))
}

\strong{UpsetPlotData} --- a pre-processed object (returned by this function)
is returned unchanged (with a warning if \code{group_by} is also provided).
}

\keyword{internal}
