Parse query rules to R filtering expression
queryToExpr.Rd
The function takes a list of condition rules provided by the widget (input[[<widget-name>]]
) and
returns valid R expression that can be used for example in filter function.
Arguments
- query
Query definition (see queryRule and queryGroup).
- keep_na
Should query keep or exclude missing values?
- .queryBuilderConfig
R6 class object storing query configuration. See queryBuilderConfigClass.
Examples
query <- queryGroup(
condition = "AND",
queryGroup(
queryRule(
field = "Species",
operator = "equal",
value = "setosa"
),
queryRule(
field = "Petal.Length",
operator = "less",
value = 1.2
)
)
)
queryToExpr(query)
#> Species == "setosa" & Petal.Length < 1.2
dplyr::filter(iris, !!queryToExpr(query))
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 4.3 3.0 1.1 0.1 setosa
#> 2 4.6 3.6 1.0 0.2 setosa