Description
Retain option allows you to copy one or more columns into the final
analytic data set. By default, the result column name is the same as
the input column name, but this can be changed. If a specific type is
specified, it results in casting the retained column.
The Retain transformation is supported for all valid data types.
Note:
The object of this class is passed to "retain" argument of
td_transform_valib()
.
Usage
tdRetain(columns, datatype=NULL)
Arguments
columns |
Required Argument. | ||||||||||||||||||||||||||||||||||||
datatype |
Optional Argument.
Notes:
Examples:
Types: character |
Value
An object of tdRetain class.
Examples
Notes:
# 1. To run any transformation, user needs to use td_transform_valib()
# function.
# 2. To do so set option 'val.install.location' to the database name
# where Vantage analytic library functions are installed.
# 3. Datasets used in these examples can be loaded using Vantage Analytic
# Library installer.
# Get the current context/connection
con <- td_get_context()$connection
# Set the option 'val.install.location'.
options(val.install.location = "SYSLIB")
# Create object(s) of class "tbl_teradata".
sales <- tbl(con, "sales")
sales
# Example: Shows retaining some column unchanged and some with name or
# datatype change.
# Retain columns 'accounts' and 'Feb' as is.
rt_1 <- tdRetain(columns=c("accounts", "Feb"))
# Retain column 'Jan' with name as 'january'.
rt_2 <- tdRetain(columns=list("Jan"="january"))
# Retain column 'Mar' and 'Apr' with name as 'march and 'april' with
# datatype changed to 'bigint'.
rt_3 <- tdRetain(columns=list("Mar"="march", "Apr"="april"),
datatype="bigint")
# Perform the retain transformation using td_transform_valib() function.
obj <- td_transform_valib(data=sales, retain=c(rt_1, rt_2, rt_3))
obj$result