shorten_condition function

Shorten predicates within conditions

Shorten predicates within conditions

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

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 base::abbreviate();
  • "abbrev8": predicates are abbreviated to at most 8 characters using base::abbreviate();
  • "none": no shortening is applied; predicates remain unchanged.
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".

Returns

A character vector of conditions with predicates shortened according to the specified method.

Details

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") shorten_condition(c("{helloWorld=1}", "{helloWorld=2}", "{c=3,helloWorld=1}"), method = "abbrev4") shorten_condition(c("{helloWorld=1}", "{helloWorld=2}", "{c=3,helloWorld=1}"), method = "abbrev8") shorten_condition(c("{helloWorld=1}", "{helloWorld=2}"), method = "none")

See Also

format_condition(), parse_condition(), is_condition(), remove_ill_conditions(), base::abbreviate()

Author(s)

Michal Burda

Other functions in nuggets

Related functions from the same R package