This function takes a character vector of conditions and shortens the predicates within each condition according to a specified method.
Details
Each element of x must be a condition formatted as a string, e.g.
"{a=1,b=100,c=3}" (see format_condition()). The function then
shortens the predicates in each condition based on the selected method:
"letters": predicates are replaced with single letters from the English alphabet, starting withAfor the first distinct predicate;"abbrev4": predicates are abbreviated to at most 4 characters usingarules::abbreviate();"abbrev8": predicates are abbreviated to at most 8 characters usingarules::abbreviate();"none": no shortening is applied; predicates remain unchanged.
Predicate shortening is useful for visualization or reporting, especially
when original predicate names are long or complex. Note that shortening is
applied consistently across all conditions in x.
Examples
shorten_condition(c("{a=1,b=100,c=3}", "{a=2}", "{b=100,c=3}"),
method = "letters")
#> [1] "{A,B,C}" "{D}" "{B,C}"
shorten_condition(c("{helloWorld=1}", "{helloWorld=2}", "{c=3,helloWorld=1}"),
method = "abbrev4")
#> [1] "{hllW=1}" "{hllW=2}" "{c=3,hllW=1}"
shorten_condition(c("{helloWorld=1}", "{helloWorld=2}", "{c=3,helloWorld=1}"),
method = "abbrev8")
#> [1] "{hellWrld=1}" "{hellWrld=2}" "{c=3,hellWrld=1}"
shorten_condition(c("{helloWorld=1}", "{helloWorld=2}"),
method = "none")
#> [1] "{helloWorld=1}" "{helloWorld=2}"
