afl: Create AFL expressions from R expressions

View source: R/afl_utils.R

aflR Documentation

Create AFL expressions from R expressions

Description

This is a convenience function for AFL generation.

Usage

afl(..., envir = parent.frame())

Arguments

...

In the ellipsis arg, any R functions right after a pipe sign '|“ is converted to a scidb operator of the same name. All regular functions are first evaluated in the calling environment, and then convereted to strings depending on the result types. ArrayOp => ArrayOp$to_afl(), v:NonEmptyVector => paste(v, collapse=','), NULL is ignored.

envir

The environment where expressions are evaluated. Default: the calling env.

Details

Any a | op_name(b) call will be translated to op_name(a, b) in R, then translated to AFL: op_name(a, b)

Any a | op_name call will be translated to op_name(a) in R, then translated to AFL: op_name(a)

Where a, b can be any ArrayOpBase instance, array name or array opertion or AFL expression; op_name can be any scidb operator or function name.

Using this syntax, we can chain multiple AFL operators

E.g.1. 'array' | filter('a > 3 and b < 4') | project('a', 'b') will be translated into: ⁠project(filter(array, a > 3 and b < 4), 'a', 'b')⁠

E.g.2.'array' | filter(a > 3) | op_count => op_count(filter(array, a > 3))

Value

AFL string


Paradigm4/ArrayOpR documentation built on Dec. 11, 2023, 5:59 a.m.