Learn R Programming

admisc (version 0.4)

Brackets: Extract information from a multi-value SOP/DNF expression

Description

Functions to extract information from an expression written in SOP - sum of products form, (or from the canonical DNF - disjunctive normal form) for multi-value causal conditions. It extracts either the values within brackets, or the causal conditions' names outside the brackets.

Usage

insideBrackets(x, type = "{", invert = FALSE)
outsideBrackets(x, type = "{")
curlyBrackets(x, outside = FALSE)
roundBrackets(x, outside = FALSE)

Arguments

x

Character, a DNF/SOP expression.

type

Brackets type: curly, round or square

invert

Logical, if activated returns whatever is not within the brackets

outside

Logical, if activated returns the conditions' names outside the brackets

Details

Expressions written in SOP - sum of products are used in Boolean logic, signaling a disjunction of conjunctions.

These expressions are useful in Qualitative Comparative Analysis, a social science methodology that is employed in the context of searching for causal configurations that are associated with a certain outcome.

They are also used to draw Venn diagrams with the package venn, which draws any kind of set intersection (conjunction) based on a custom SOP expression.

The functions curlyBrackets and roundBrackets are just special cases of the functions insideBrackets and outsideBrackets, using the argument type as either "\{" or "(".

The function outsideBrackets itself can be considered a special case of the function insideBrackets, when it uses the argument invert = TRUE.

Examples

Run this code
# NOT RUN {
dnf <- "A{1} + B{2}C{0}"

insideBrackets(dnf) # 1, 2, 0

insideBrackets(dnf, invert = TRUE) # A, B, C

curlyBrackets(dnf) # 1, 2, 0

curlyBrackets(dnf, outside = TRUE) # A, B, C
# }

Run the code above in your browser using DataLab