Teradata Package for R Function Reference | 17.00 - 17.00 - Pack - Teradata Package for R

Teradata® Package for R Function Reference

Teradata Package for R
Release Number
July 2021
Last Update
August 2022
Content Type
Programming Reference
Publication ID
English (United States)
Last Update


The Pack function packs data from multiple input columns into a single column. The packed column has a virtual column for each input column. By default, virtual columns are separated by commas and each virtual column value is labeled with its column name.
Note: This function is only available when tdplyr is connected to Vantage 1.1 or later versions.


  td_pack_sqle (
    data = NULL,
    input.columns = NULL,
    output.column = NULL,
    delimiter = ",",
    include.column.name = TRUE,
    data.order.column = NULL



Required Argument.
Specifies the tbl_teradata containing the input attributes.


Optional Argument.
Specifies Order By columns for "data".
Values to this argument can be provided as a vector, if multiple columns are used for ordering.
Types: character OR vector of Strings (character)


Optional Argument.
Specifies the names of the input columns to pack into a single output column. These names become the column names of the virtual columns. By default, all input tbl_teradata columns are packed into a single output column. If you specify this argument, but do not specify all input tbl_teradata columns, the function copies the unspecified input tbl_teradata columns to the output tbl_teradata.
Types: character OR vector of Strings (character)


Required Argument.
Specifies the name to give to the packed output column.
Types: character


Optional Argument.
Specifies the delimiter (a string) that separates the virtual columns in the packed data.
Default Value: ","
Types: character


Optional Argument.
Specifies whether to label each virtual column value with its column name (making the virtual column "input_column:value").
Default Value: TRUE
Types: logical


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


    # Get the current context/connection
    con <- td_get_context()$connection
    # Load example data.
    loadExampleData("pack_example", "ville_temperature")
    # Create object(s) of class "tbl_teradata".
    # The input table, ville_temperature, contains temperature readings for the cities
    # Nashville and Knoxville, in the state of Tennessee.
    ville_temperature <- tbl(con, "ville_temperature")
    # Example 1 - Default Argument Values.
    # Default values used for arguments "delimiter" and "input.columns".
    td_pack_out1 <- td_pack_sqle(data = ville_temperature,
                      input.columns = c("city", "state", "period", "temp_f"),
                      output.column = "packed_data",
                      delimiter = ",",
                      include.column.name = TRUE
    # Example 2 - Nondefault Argument Values.
    # This example uses nondefault values for arguments "delimiter" and "include.column.name".
    td_pack_out2 <- td_pack_sqle(data = ville_temperature,
                      input.columns = c("city", "state", "period", "temp_f"),
                      output.column = "packed_data",
                      delimiter = "|",
                      include.column.name = FALSE