Description
The Pivot function pivots data that is stored in rows into columns.
It outputs a table whose columns are based on the individual values from an input table column.
The schema of the output table depends on the arguments to the function.
The columns in the output table appear in the order specified by the "data.order.column" argument.
The function handles missing or NULL values automatically.
Usage
td_pivot_mle ( data = NULL, partition.columns = NULL, target.columns = NULL, pivot.column = NULL, pivot.keys = NULL, numeric.pivotkey = FALSE, num.rows = NULL, data.sequence.column = NULL, data.partition.column = NULL, data.order.column = NULL )
Arguments
data |
Required Argument. |
data.partition.column |
Required Argument. |
data.order.column |
Optional Argument. |
partition.columns |
Required Argument. |
target.columns |
Required Argument. |
pivot.column |
Optional Argument. Required if you omit the argument "num.rows". |
pivot.keys |
Optional Argument. Required if you specify pivot.column. |
numeric.pivotkey |
Optional Argument. |
num.rows |
Optional Argument. Required if you omit pivot.column. |
data.sequence.column |
Optional Argument. |
Value
Function returns an object of class "td_pivot_mle" which is a named list
containing Teradata tbl object.
Named list member can be referenced directly with the "$" operator
using name: result.
Examples
# Get the current context/connection con <- td_get_context()$connection # Load example data. loadExampleData("pivot_example", "pivot_input") # Create remote tibble objects. pivot_input <- tbl(con, "pivot_input") # This example specifies the pivot.column argument and with the pivot.keys argument, which specifies # the values from the pivot.column to use as pivot keys. Because pivot.keys does not include 'dewpoint', the # function ignores rows that include 'dewpoint'. td_pivot_out1 <- td_pivot_mle(data = pivot_input, data.partition.column = c("sn","city","week"), data.order.column = c("week","attribute"), partition.columns = c("sn","city", "week"), target.columns = c("value1"), pivot.column = "attribute", pivot.keys = c("temp","pressure") ) # Specify the num.rows argument instead of specifying the pivot.column argument. td_pivot_out2 <- td_pivot_mle(data = pivot_input, data.partition.column = c("sn","city","week"), data.order.column = c("week","attribute"), partition.columns = c("sn","city", "week"), target.columns = c("value1"), num.rows = 3 )