generate: Attribute Creation

Description Usage Arguments Details Value Author(s) Examples

Description

Generate appends columns to each row of the data by evaluating the given expression

Usage

1

Arguments

x

an object of class "data"

...

a list of name = expression pairs. It is required that every argument to be named, as that name is used as the column name for the generated data.

Details

It is important to note that generation adds overhead to the evaluation process. Creating an additional attribute solely for use in a single GLA or filtering is discouraged because of this. Generate is more appropiately used in conjunction with either joining, writing to the disc, or several actions using the same new attribute. See ‘examples’ below for more information.

Value

An object of class "data" with the additonal columns.

Author(s)

Jon Claus at Tera Insights LLC

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## inefficient usage
data <- Read(lineitem100g)
data <- Generate(data, cost = l_extended_price * (1 + l_tax) * (1 -
l_discount))
data <- data[cost < 100]

## this is also inefficient
data <- Read(lineitem100g)
data <- Generate(data, cost = l_extended_price * (1 + l_tax) * (1 -
l_discount), stock = l_quantity * l_extended_price)
data <- data[cost < 100]
data <- data[stock > 10]

## advised usage
supplier <- Read(supplier100g)
lineitem <- Read(lineitem100g)
lineitem <- Generate(lineitem, stock = l_quantity * l_extended_price)
data <- Join(supplier, s_acctbal, lineitem, stock)

tera-insights/gtBase documentation built on May 31, 2019, 8:35 a.m.