Skip to contents

This function takes a character vector of conditions and shortens the predicates within each condition using 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 method to use for shortening the predicates. It must be one of "letters", "abbrev4", or "abbrev8". Default is "letters".

Value

A character vector of conditions with shortened predicates.

Details

Each value in x is a condition formatted as a string, e.g., "{a=1,b=100,c=3}" (see format_condition()). The function shortens the predicates in each condition according to the specified method. The available methods are:

  • "letters": predicates are replaced with single letters from the English alphabet, starting with A for the first predicate;

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

  • "abbrev8": predicates are abbreviated to 8 characters using abbreviate() function;

  • "none": no shortening is applied, predicates remain unchanged.

Author

Michal Burda

Examples

shorten_condition(c("{a=1,b=100,c=3}", "{a=2}", "{b=100,c=3}"),
                  method = "letters")
#> [1] "{A,C,D}" "{B}"     "{C,D}"  

shorten_condition(c("{helloWorld=1}", "{helloWorld=2}", "{c=3, helloWorld=1}"),
                  method = "abbrev4")
#> [1] "{hllW=1}"     "{hllW=2}"     "{c=3,hllW=1}"