TApply: Applies a transformation object on a StQ or data.table.

Description Usage Arguments Details Value Examples

Description

TApply returns a transformed object according to the transformation rules.

Usage

1
2
3
4
5
6
7
TApply(x, Tr)

## S4 method for signature 'data.table,StQT'
TApply(x, Tr)

## S4 method for signature 'StQ,StQT'
TApply(x, Tr)

Arguments

x

Object of class StQ or data.table with data to transform

Tr

Object of class StQT with the transformation we are going to apply.

Details

There are three kinds of transformation rules: internal functions, row insertion and column insertion.

Parameter domain specifies the subset of the dataset where we are going to do the calculation. Parameter by sets the variables where we are applying the rule by. Parameter order orders the table, previously to apply the transformation. Parameter key (irrelevant for data.table) sets which of the variables are qualifiers.

Value

StQ or data.table respectively with transformed data

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
require(data.table)
dt <- data.table(Region = c("1","2","3"), GDP = c(1.38,0.94,1.23))
dt
T1 <- NewStQT(data.frame(
  output = "Region='Total',GDP",
  fun = "sum",
  input = "GDP",
  stringsAsFactors = FALSE))
TApply(dt,T1)
require(StQ)
data(ExampleStQ)
rules <- data.frame(domain = c('','Turnover > 0'),
                    output = c('AggTurnover','LogTurnover'),
                       fun = c('sum','log'),
                     input = c('Turnover','Turnover'),
                        by = c('NACE09',''),
                       key = c('NACE09',''),
                         stringsAsFactors = FALSE)
T2 <- NewStQT(rules)
(ExampleStQ2 <- TApply(ExampleStQ,T2))

Luis-Sanguiao/StQT documentation built on May 7, 2019, 2:03 p.m.