This function takes a dataframe with LimeSurvey (LS) variable codes and values, and builds a nested set of LimeSurvey Equation Manager (LSEM) if/then/else equations where the variable code in each row (in the varCodeCol) is compared to the corresponding value (i.e. the value in the same row in the valueCol column) using the operator specified in that row in the operatorCol column (or the == operator, if no operator is specified). In the case of a match, the value in the corresponding recodeToCol column is returned. If there is no match, the comparison on the next row is evaluated, all the way down. If nothing matches, the elseExpr is returned.

ls_recodeTable_to_equations(
  data,
  varCodeCol = limonaid::opts$get("recTab2Eq_varCodeCol"),
  valueCol = limonaid::opts$get("recTab2Eq_valueCol"),
  recodeToCol = limonaid::opts$get("recTab2Eq_recodeToCol"),
  operatorCol = limonaid::opts$get("recTab2Eq_operatorCol"),
  elseExpr = limonaid::opts$get("eq_elseExpr"),
  naok = TRUE
)

Arguments

data

The dataframe.

varCodeCol

The name or index of the column with the variable code.

valueCol

The name or index of the column with the values to compare the value of the variable code to.

recodeToCol

The name or index of the column with the value to return in the case of a match.

operatorCol

The name or index of the column with the operator used to build each logical expression.

elseExpr

The value to return if there are no matches.

naok

Whether to append ".NAOK" to variable codes by default.

Value

A character value.

Examples

### Provide later