Convert character vector of conditions into a list of vectors of predicates
Source:R/parse_condition.R
parse_condition.Rd
Function takes a character vector of conditions and returns a list of vectors
of predicates. Each element of the list corresponds to one condition. The
condition is a string with predicates separated by commas and enclosed in
curly braces, as returned by format_condition()
. The function splits the
condition string into a vector of predicates.
Details
If multiple vectors of conditions are passed, each of them is processed separately and the result is merged into a single list element-wisely. If the lengths of the vectors are different, the shorter vectors are recycled.
Examples
parse_condition(c("{a}", "{x=1, z=2, y=3}", "{}"))
#> [[1]]
#> [1] "a"
#>
#> [[2]]
#> [1] "x=1" "z=2" "y=3"
#>
#> [[3]]
#> character(0)
#>
parse_condition(c("{b}", "{x=1, z=2, y=3}", "{q}", "{}"),
c("{a}", "{v=10, w=11}", "{}", "{r,s,t}"))
#> [[1]]
#> [1] "b" "a"
#>
#> [[2]]
#> [1] "x=1" "z=2" "y=3" "v=10" "w=11"
#>
#> [[3]]
#> [1] "q"
#>
#> [[4]]
#> [1] "r" "s" "t"
#>