AFLUtils | R Documentation |
Normally we don't need these functions. But in case we do, they are flexible in constructing high-order AFL expressions, e.g. AFL raw string or expressions generated in one place and used in other places with or without modification.
e_to_afl()
Convert filter expression(s) to AFL filter
AFLUtils$e_to_afl(e, regex_func = "regex", ignore_case = TRUE)
e
A list of R expression(s). If more than one expression is provided, they will be joined with logic AND.
regex_func
A string of regex function implementation, default 'regex'. Due to scidb compatiblity issue with its dependencies, the regex function from boost library may not be available Currently supported options include 'rsub', and 'regex'
ignore_case
A Boolean, default TRUE. If TRUE, ignore case in string match patterns. Otherwise, perform case-sensitive regex matches.
An AFL filter string
args_to_expressions()
Convert API ... args to an R expression vector (deprecated)
Some API functions include ... arg to represent arbitrary search criteria. This provides flexibility and simplifies API function signatures, but only supports limited advanced search, e.g. xxx_contains, xxx_range, xxx_not.
Eg. name_contains = 'str' => name %contains% 'str' Eg. value_range = c(1, 9) => c(value >= 1, value <= 9)
AFLUtils$args_to_expressions(..., .dots = NULL)
...
API ellipsis args
.dots
Explicitly provide a parameter list. If not NULL, the ellipsis params are ignored
A list of AFL expressions in R
e()
Create a list of R expressions
The ... ellipsis arg can include arbitrary expressions, where all names are preserved in their literal forms, except for those prefixed with !! (double exclamation marks) which will be evaluated to their actual values in the calling environment.
Besides common comparison operators including ==
, >
, <
, >=
, <=
, !=
, there are a few special operators
supported to ease AFL generation:
%in%
semantically similar to R. a %in% !!c(1,2,3)
will be translated to (a == 1 or a == 2 or a == 3)
%like%
for string regex matching.
AFLUtils$e(...)
...
The ellipsis arg can have multiple items as expressions, but NO named items as in a named list.
A list of R expressions
e_merge()
Merge multiple R expressions into one
Merge an ExprsList into a single Expression so that it can be used as a FilterExpr
AFLUtils$e_merge(el, mode = "AND")
el
A list of R expressions
mode
'AND' | 'OR'. Logical relationships when merging the expressions.
R expression
join_fields()
Just multple fields with sep = ','
Default behavior: paste(..., sep = sep, collapse = sep)
where sep = ','
afl(...) will convert vectors to joined strings separated by ,
.
This function is useful in concatenating multiple vectors in parallel,
e.g. joining a new field vector and expression vector for the apply
operator.
AFLUtils$join_fields(..., sep = ",")
...
Multiple string vectors
sep
A single character string, defaullt ",", as field separator.
validate_filter_expr()
Validate a filter expression
Current only report errors on:
Name symbols that are not known schema fields, defined by
param all_fields
Non-atomic R 'values' in the expression
AFLUtils$validate_filter_expr(filter_expr, all_fields)
filter_expr
AFL captured as a single R expression
all_fields
A list of strings as the scope of valid fields
A list object with named elements: success:bool, absent_fields: c(”), error_msgs: c(”)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.