% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/brackets.R
\name{betweenBrackets}
\alias{betweenBrackets}
\alias{insideBrackets}
\alias{outsideBrackets}
\alias{curlyBrackets}
\alias{squareBrackets}
\alias{roundBrackets}
\title{Extract information from a multi-value SOP/DNF expression}
\arguments{
\item{x}{A DNF/SOP expression.}

\item{type}{Brackets type: curly, round or square.}

\item{invert}{Logical, if activated returns whatever is not within the
brackets.}

\item{outside}{Logical, if activated returns the condition names outside the
brackets.}

\item{regexp}{Optional regular expression to extract information with.}

\item{expression}{A DNF/SOP expression.}

\item{snames}{A string containing the sets' names, separated by commas.}

\item{noflevels}{Numerical vector containing the number of levels for each
set.}

\item{simplify}{Logical, remove redundant expressions after expansion.}
}
\description{
Functions to extract information from an expression written in SOP, or in the
canonical DNF, for multi-value causal conditions. They extract either the
values within brackets, or the causal condition names outside the brackets.
}
\details{
Expressions written in SOP are used in Boolean logic, signaling a
disjunction of conjunctions.

These expressions are useful in Qualitative Comparative Analysis, a social
science methodology used to search for causal configurations associated with
a certain outcome.

They are also used to draw Venn diagrams with package \code{venn}, which draws
any kind of set intersection based on a custom SOP expression.

\code{curlyBrackets()}, \code{squareBrackets()} and \code{roundBrackets()} are special cases
of \code{betweenBrackets()} and \code{outsideBrackets()}, using curly, square or round
brackets through the \code{type} argument.

\code{outsideBrackets()} can also be seen as a special case of
\code{betweenBrackets(invert = TRUE)}.

SOP expressions are usually written using curly brackets for multi-value
conditions but, to allow evaluation of unquoted expressions through R's
parser, unquoted expressions should use square brackets and conjunctions
should always use the product \code{*} sign.

Sufficiency is recognized as \code{"=>"} in quoted expressions but this does not
pass over R's parsing system in unquoted expressions. To overcome this
problem, it is best to use the single arrow \code{"->"} notation. Necessity is
recognized as either \code{"<="} or \code{"<-"}, both being valid in quoted and
unquoted expressions.
}
\examples{
sop <- "A[1] + B[2]*C[0]"

betweenBrackets(sop)
betweenBrackets(sop, invert = TRUE)

# unquoted (valid) SOP expressions are allowed, same result
betweenBrackets(A[1] + B[2]*C[0])

# curly brackets are also valid in quoted expressions
betweenBrackets("A{1} + B{2}*C{0}", type = "{")
curlyBrackets("A{1} + B{2}*C{0}")
curlyBrackets("A{1} + B{2}*C{0}", outside = TRUE)

squareBrackets(A[1] + B[2]*C[0])
squareBrackets(A[1] + B[2]*C[0], outside = TRUE)

}
\author{
Adrian Dusa
}
\keyword{functions}
