[R] Subsets of Boolean string model
Alrik Thiem
alrik.thiem at gmail.com
Mon Jan 5 12:48:06 CET 2015
Dear R-help list,
I have a problem regarding text manipulation in R, where my basic knowledge
doesn't suffice anymore. It might be a bigger problem, but any help would be
greatly appreciated and acknowledged.
As input, I have a character string representing some Boolean function, such
as "aB+Bc+D", for instance, where "+" means OR, AND has been omitted between
two factors represented by single letters, and lower-case "x" simply means
"NOT X".
Now I would like to form all sub-models without including models that are
not redundancy-free. For example, "D", "a+D" and "B+c+D" would be ok, but
"aB+B+D", "B+Bc" and "B+B+D" would not because "B" is a (strict) superset of
both "aB" and "Bc" as well as a (trivial) superset of "B".
With regards to "D+aB+Bc", there would thus be 24 permissible and unique
sub-models (including the empty set):
"a", "B", "c", "D", "aB", "Bc", "a+B", "a+c", "a+D", "B+c", "B+D", "c+D",
"a+Bc", "aB+c", "aB+D", "aB+Bc", "Bc+D", "a+B+D", "a+c+D", "a+Bc+D",
"aB+c+D", "B+c+D", "aB+Bc+D", "".
How could I generate a character vector of all permissible and unique
sub-models from any Boolean function of the form given above?
Best wishes,
Alrik
********************************
Alrik Thiem
Post-Doctoral Researcher
Department of Philosophy
University of Geneva
Rue de Candolle 2
CH-1211 Geneva
+41 76 527 80 83
http://www.alrik-thiem.net
http://www.compasss.org
More information about the R-help
mailing list