Skip to contents

This function takes a character vector of conditions and shortens the predicates within each condition according to a specified method.

Usage

shorten_condition(x, method = "letters")

Arguments

x

A character vector of conditions, each formatted as a string (e.g., "{a=1,b=100,c=3}").

method

A character scalar specifying the shortening method. Must be one of "letters", "abbrev4", "abbrev8", or "none". Defaults to "letters".

Value

A character vector of conditions with predicates shortened according to the 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 with A for the first distinct predicate;

  • "abbrev4": predicates are abbreviated to at most 4 characters using abbreviate();

  • "abbrev8": predicates are abbreviated to at most 8 characters using 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.

Author

Michal Burda

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}"