VarNamesToFormula: Return a list of formulas for dcasting long data sets.

Description Usage Arguments Value Examples

Description

VarNamesToFormula returns a list of formulas (in the sense of functions dcast and melt from the package data.table) for each compound variable name included in the input vector VarNames.

This function returns a data.table with two colums: the column Variable with the root names of each compound variable name, and the column Form with the corresponding formula having IDQual qualifiers and the sort of variable (IDDD, IDQual or NonIDQual) in its lhs and the variable qualifiers whose values appear as suffixes in the compound variable names in the rhs. Duplicate entries in the resulting data.table drop out.

VarNamesToFormula is designed to be applied on compound variable names including suffixes with qualifier values. It is fundamentally designed for the internal use in the construction of editing strategies, but it can also be of utility in some scripts.

Usage

1
2
3
4
VarNamesToFormula(VarNames, DD)

## S4 method for signature 'character,DD'
VarNamesToFormula(VarNames, DD)

Arguments

VarNames

Character vector with compound variable names.

DD

Object of class DD with the definition and properties of the variables.

Value

data.table with columns Variable and Form. The column Variable indicates the root name of each input variable name and the column Form presents the corresponding formula.

Examples

1
2
3
4
5
6
data(ExampleDD)
VarNamesToFormula('Turnover', ExampleDD)

VarNamesToFormula(c('Employees_1.', 'Employees_2.2', 'Employees'), ExampleDD)

VarNamesToFormula(c('Turnover', 'Employees_1.', 'Employees_2.2', 'Employees'), ExampleDD)

david-salgado/StQ documentation built on Aug. 12, 2021, 3:23 p.m.