BuildDD: Constructor of objects of class DD

Description Usage Arguments Value Examples

View source: R/BuildDD.R

Description

This constructor returns an object of class DD. The input parameter is a named list of objects of classes VarNameCorresp (named VNC) and data.table. Notice that the names of this list must be, apart from VNC, any of 'ID', 'MicroData', 'ParaData', 'Aggregates', AggWeights', 'Other'.

Usage

1
2
3
4
5
6
7
BuildDD(
  Data = list(ID = data.table(Variable = character(0), Sort = character(0), Class =
    character(0), Length = character(0), Qual1 = character(0), ValueRegExp =
    character(0)), MicroData = data.table(Variable = character(0), Sort = character(0),
    Class = character(0), Length = character(0), Qual1 = character(0), ValueRegExp =
    character(0)))
)

Arguments

Data

A named list of objects of classes VarNameCorresp and data.table.

Value

An object of class DD with components specified in the input parameter Data. Components 'ID' and/or 'MicroData' not being specified are set as an empty data.table.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
library(data.table)
VarListVNC <- list(
  ID = data.table(IDQual = c('NumIdEst', rep('', 4)),
                  NonIDQual = rep('', 5),
                  IDDD = c('', 'Name', 'Surname', 'PostalAddr', 'PhoneNo'),
                  NumIdEst = c('', rep('.', 4)),
                  UnitName = c('numidest', 'nombre', 'apellidos', 'direccion', 'telefono'),
                  InFiles = rep('FI', 5)),
  MicroData = data.table(IDQual = c('NumIdEst', rep('', 2)),
                         NonIDQual = c('', 'Market', ''),
                         IDDD = c(rep('', 2), 'NewOrders'),
                         NumIdEst = c(rep('', 2), '.'),
                         Market = c(rep('', 2), '1.'),
                         UnitName = c('numidest', '', 'cp09'),
                         InFiles = rep('FF, FD, FG', 3)),
 Aggregates = data.table(IDQual = c('Province', 'NACE', 'MarketR', ''),
                         NonIDQual = rep('', 4),
                         IDDD = c('', '', '', 'TotalTurnover'),
                         Province = c('', '', '', '.'),
                         NACE = c('', '', '', '.'),
                         MarketR = c('', '', '', '1.'),
                         UnitName = c('provincia', 'actividad', '', 'cn01'),
                         InFiles = rep('FP', 4)))
                     
VNC <- BuildVNC(VarListVNC)

IDdt <- data.table(Variable = c('NumIdEst', 'Name', 'Surname', 'PostalAddr', 'PhoneNo'),
                   Sort = c('IDQual', rep('IDDD', 4)),
                   Class = rep('character', 5),
                   Length = c('11', '15', '15', '20','9'),
                   Qual1 = c('', rep('NumIdEst', 4)),
                   ValueRegExp = c('[0-9]{9}PP', '.+', '.+', '.+', '(6|9)[0-9]{8}'))
Microdt <- data.table(Variable = c('NumIdEst', 'Market', 'NewOrders'),
                      Sort = c('IDQual', 'NonIDQual', 'IDDD'),
                      Class = c(rep('character', 2), 'numeric'),
                      Length = c('11', '2', '7'),
                      Qual1 = c(rep('', 2), 'NumIdEst'),
                      ValueRegExp = c('[0-9]{9}PP', '.+', '([0-9]{1, 10}| )'))
BuildDD(Data = list(VNC = VNC, ID = IDdt, MicroData = Microdt))

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