queryToExpr: Parse query rules to R filtering expression

View source: R/parse_results.R

queryToExprR Documentation

Parse query rules to R filtering expression

Description

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.

Usage

queryToExpr(query, keep_na = FALSE, .queryBuilderConfig = queryBuilderConfig)

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.

Value

Object of class 'call'. A filtering expression that can be passed to 'dplyr'-based filtering methods.

Examples


query <- queryGroup(
  condition = "AND",
  queryGroup(
    queryRule(
      field = "Species",
      operator = "equal",
      value = "setosa"
    ),
    queryRule(
      field = "Petal.Length",
      operator = "less",
      value = 1.2
    )
  )
)
queryToExpr(query)
dplyr::filter(iris, !!queryToExpr(query))


queryBuilder documentation built on Oct. 7, 2024, 1:19 a.m.