Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

factorize

Factorize Boolean expressions


Description

This function finds all combinations of common factors in a Boolean expression written in SOP - sum of products. It makes use of the function simplify(), which uses the function minimize() from package QCA). Users are highly encouraged to install and load that package, despite not being present in the Imports field (due to circular dependency issues).

Usage

factorize(input, snames = "", noflevels = NULL, pos = FALSE, ...)

Arguments

input

A string representing a SOP expression, or a minimization object of class "qca".

snames

A string containing the sets' names, separated by commas.

noflevels

Numerical vector containing the number of levels for each set.

pos

Logical, if possible factorize using product(s) of sums.

...

Other arguments (mainly for backwards compatibility).

Details

Factorization is a process of finding common factors in a Boolean expression, written in SOP - sum of products. Whenever possible, the factorization can also be performed in a POS - product of sums form.

Conjunctions should preferably be indicated with a star * sign, but this is not necessary when conditions have single letters or when the expression is expressed in multi-value notation.

The argument snames is only needed when conjunctions are not indicated by any sign, and the set names have more than one letter each (see function translate() for more details).

The number of levels in noflevels is needed only when negating multivalue conditions, and it should complement the snames argument.

If input is an object of class "qca" (the result of the function minimize() from package QCA), a factorization is performed for each of the minimized solutions.

Value

A named list, each component containing all possible factorizations of the input expression(s), found in the name(s).

Author(s)

Adrian Dusa

References

Ragin, C.C. (1987) The Comparative Method. Moving beyond qualitative and quantitative strategies, Berkeley: University of California Press

See Also

Examples

## Not run: 
  # make sure the package QCA is loaded
  library(QCA)

## End(Not run)

# typical example with redundant conditions
factorize(a~b~cd + a~bc~d + a~bcd + abc~d)

# results presented in alphabetical order
factorize(~one*two*~four + ~one*three + three*~four)

# to preserve a certain order of the set names
factorize(~one*two*~four + ~one*three + three*~four,
          snames = c(one, two, three, four))

# using pos - products of sums
factorize(~a~c + ~ad + ~b~c + ~bd, pos = TRUE)

## Not run: 
# using an object of class "qca" produced with function minimize()
# in package QCA

pCVF <- minimize(CVF, outcome = "PROTEST", incl.cut = 0.8,
                 include = "?", use.letters = TRUE)

factorize(pCVF)

# using an object of class "deMorgan" produced with negate()
factorize(negate(pCVF))

## End(Not run)

admisc

Adrian Dusa's Miscellaneous

v0.12
GPL (>= 3)
Authors
Adrian Dusa [aut, cre, cph] (<https://orcid.org/0000-0002-3525-9253>)
Initial release
2021-03-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.