Teradata Package for R Function Reference | 17.20 - NumApply - Teradata Package for R - Look here for syntax, methods and examples for the functions included in the Teradata Package for R.

Teradata® Package for R Function Reference

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for R
Release Number
17.20
Published
March 2024
Language
English (United States)
Last Update
2024-05-03
dita:id
TeradataR_FxRef_Enterprise_1720
Product Category
Teradata Vantage

NumApply

Description

Apply predefined numeric operation on specified target columns.

Usage

  td_num_apply_sqle (
      data = NULL,
      target.columns = NULL,
      output.columns = NULL,
      accumulate = NULL,
      apply.method = NULL,
      sigmoid.style = NULL,
      in.place = NULL,
      ...
  )

Arguments

data

Required Argument.
Specifies the input tbl_teradata.
Types: tbl_teradata

target.columns

Required Argument.
Specifies the name(s) of the column(s) in "data" to perform numeric operations on.
Types: character OR vector of Strings (character)

output.columns

Optional Argument.
Specifies the name(s) of the output column(s) to be generated.
An output column name cannot exceed 128 characters.
By default, with "in.place" set to FALSE, 'target_column_operator'; otherwise same as "target_column" names.
Notes:

  1. If any 'target_column_operator' exceeds 128 characters, specify an "output_column" for each target_column.

  2. Ignored with "in.place" set to TRUE.

Types: character OR vector of Strings (character)

accumulate

Optional Argument.
Specifies the name(s) of input tbl_teradata column(s) to copy to the output.
Types: character OR vector of Strings (character)

apply.method

Required Argument.
Specifies the numeric operator/method.
Permitted Values:

  • EXP - Raises e (base of natural logarithms) to power of value, where e = 2.71828182845905.

  • LOG - Computes base 10 logarithm of value.

  • SIGMOID - Applies sigmoid function to value. See "sigmoid.style".

  • SININV - Computes inverse hyperbolic sine of value.

  • TANH - Computes hyperbolic tangent of value.

Types: character

sigmoid.style

Optional Argument, required when "apply.method" is 'sigmoid'.
Specifies the sigmoid style.
Permitted Values:

  • LOGIT

  • MODIFIEDLOGIT

  • TANH

Default Value: LOGIT
Types: character

in.place

Optional Argument.
Specifies whether the output columns have the same names as the target columns.
When set to TRUE, function effectively replaces each value in each target column with the result of applying "apply.method" to it, otherwise copies the target columns to the output and adds output columns whose values are the result of applying "apply.method" to each value.
No target columns can be part of the "accumulate" column.
Default Value: TRUE
Types: logical

...

Specifies the generic keyword arguments SQLE functions accept.
Below are the generic keyword arguments:

persist:
Optional Argument.
Specifies whether to persist the results of the function in a table or not.
When set to TRUE, results are persisted in a table; otherwise, results are garbage collected at the end of the session.
Default Value: FALSE
Types: logical

volatile:
Optional Argument.
Specifies whether to put the results of the function in a volatile table or not.
When set to TRUE, results are stored in a volatile table, otherwise not.
Default Value: FALSE
Types: logical

Function allows the user to partition, hash, order or local order the input data. These generic arguments are available for each argument that accepts tbl_teradata as input and can be accessed as:

  • "<input.data.arg.name>.partition.column" accepts character OR vector of Strings (character) (Strings)

  • "<input.data.arg.name>.hash.column" accepts character OR vector of Strings (character) (Strings)

  • "<input.data.arg.name>.order.column" accepts character OR vector of Strings (character) (Strings)

  • "local.order.<input.data.arg.name>" accepts logical

Note:
These generic arguments are supported by tdplyr if the underlying SQL Engine function supports, else an exception is raised.

Value

Function returns an object of class "td_num_apply_sqle" which is a named list containing object of class "tbl_teradata".
Named list member(s) can be referenced directly with the "$" operator using the name(s):result

Examples

  
    
    # Get the current context/connection.
    con <- td_get_context()$connection
    
    # Load the example data.
    loadExampleData("tdplyr_example", "numerics")
    
    # Create tbl_teradata object.
    numerics <- tbl(con, "numerics")
    
    # Check the list of available analytic functions.
    display_analytic_functions()
    
    # Example 1: Apply "log" method to column "num1" in numerics.
    obj <- td_num_apply_sqle(data=numerics,
                             target.columns="integer_col",
                             apply.method="log",
                             in.place=TRUE)

    # Print the result.
    print(obj$result)

    # Example 2: Apply "sigmoid" method and "tanh" as sigmoid style.
    obj <- td_num_apply_sqle(data=numerics,
                             target.columns="decimal_col",
                             output.columns="out1",
                             apply.method="sigmoid",
                             sigmoid.style="tanh",
                             in.place=FALSE)
    
    # Print the result.
    print(obj$result)