lsem_equations.RdThese are a set of really basic functions that facilitate building LimeSurvey Expression Manager (LSEM) equations.
ls_eq_build(lhs, operator, rhs)
ls_eq_is(varCode, value, naok = TRUE)
ls_eq_isChecked(varCode, naok = TRUE)
ls_eq_isUnchecked(varCode, naok = TRUE)
ls_eq_if(cond, ifExpr, elseExpr)
ls_eq_ifRegex(regex, varCode, ifExpr, elseExpr, naok = TRUE)
ls_eq_brace(expr)
ls_eq_quote(expr)The left-hand side expression.
The operator.
The right-hand side expression.
A LimeSurvey variable code.
A value.
Whether to append ".NAOK" to the variable code.
A condition, for example created by ls_eq_build()
or ls_eq_is().
An expression.
A regular expression.
A character vector.
ls_eq_build() just pastes together its three
arguments in the same order using a space as
separator. So it's mostly used for clarity when
building LSEM equations.
ls_eq_is() uses ls_eq_build() to specify a logical
expression that is true when varCode equals value.
ls_eq_if() builds an if/then/else expression; if
cond evaluates to TRUE, the LSEM uses ifExpr;
otherwise, it uses elseExpr.
ls_eq_ifRegex checks a question against a regular expression.
ls_eq_isChecked() and ls_eq_isUnchecked() return an
expression evaluating whether a checkbox is checked (or not).
ls_eq_brace() simply embraces expr, an expression
(i.e. it prepends { and appends }).
ls_eq_quote() simply embraces expr, an expression
(i.e. it prepends ' and appends ').
ls_eq_build("questionCode", "==", "Y");
#> [1] "questionCode == Y"