shorten_condition: Shorten predicates within conditions

View source: R/shorten_condition.R

shorten_conditionR Documentation

Shorten predicates within conditions

Description

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

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 base::abbreviate();

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

Value

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

Author(s)

Michal Burda

See Also

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

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


nuggets documentation built on Nov. 5, 2025, 6:25 p.m.