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

Teradata® R Package Function Reference

Product
Teradata R Package
Release Number
16.20
Published
February 2020
Language
English (United States)
Last Update
2020-02-28
dita:id
B700-4007
lifecycle
previous
Product Category
Teradata Vantage

Description

The PathSummarizer (td_path_summarizer_mle) function takes output of the PathGenerator (td_path_generator_mle) function and returns, for each prefix in the input table, the parent and children and number of times each of its subsequences was traveled. This output can be input to the PathStart (td_path_start_mle) function.

Usage

  td_path_summarizer_mle (
      object = NULL,
      object.partition.column = NULL,
      seq.column = NULL,
      partition.names = NULL,
      count.column = NULL,
      delimiter = ",",
      hash = FALSE,
      prefix.column = NULL,
      object.order.column = NULL,
      object.sequence.column = NULL
  )

Arguments

object

Required Argument.
Specifies the name of the object returned by the td_path_generator_mle function, or the output tbl_teradata containing the generated paths.

object.partition.column

Required Argument.
Specifies Partition By columns for input table. Values to this argument can be provided as vector, if multiple columns are used for partition.
Types: character OR vector of Strings (character)

seq.column

Required Argument.
Specifies the name of the column in the input table that contains the paths.
Types: character OR vector of Strings (character)

partition.names

Required Argument.
Specifies the names of the columns that are specified in the "object.partition.column" argument. The function uses these names for output table columns. This argument and the "object.partition.column" argument must specify the same names in the same order.
Types: character OR vector of Strings (character)

count.column

Optional Argument.
Specifies the name of the column in the input table that contains the number of times a path was traveled.
Types: character OR vector of Strings (character)

delimiter

Optional Argument.
Specifies the single-character delimiter that separates symbols in the path string.
Note: Do not use any of the following characters as delimiter (they cause the function to fail): Asterisk (*), Plus (+), Left parenthesis ((), Right parenthesis ()), Single quotation mark ('), Escaped single quotation mark (\'), Backslash (\).
Default Value: ","
Types: character

hash

Optional Argument.
Specifies whether to include the hash code of the node in the output table.
Default Value: FALSE
Types: logical

prefix.column

Required Argument.
Specifies the name of the input column that contains the node prefixes.
Types: character OR vector of Strings (character)

object.order.column

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

object.sequence.column

Optional Argument.
Specifies the vector of column(s) that uniquely identifies each row of the input argument "object". The argument is used to ensure deterministic results for functions which produce results that vary from run to run.
Types: character OR vector of Strings (character)

Value

Function returns an object of class "td_path_summarizer_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("pathgenerator_example", "clickstream1")
    
    # Create remote tibble objects.
    # The table contains clickstream data, where the "path" column
    # contains symbols for the pages that the customer clicked.
    clickstream1 <- tbl(con, "clickstream1")
    
    # Example 1 - td_path_summarizer_mle() uses the output of td_path_generator_mle().
    td_path_generator_out <- td_path_generator_mle(data = clickstream1,
                                               seq.column = "path"
                                               )
    td_path_summarizer_out1 <- td_path_summarizer_mle(object = td_path_generator_out,
                                                  object.partition.column = c('prefix'),
                                                  seq.column = 'sequence',
                                                  partition.names = 'prefix',
                                                  prefix.column = 'prefix'
                                                )
    # Example 2 - Alternatively, persist and use the output table of td_path_generator_mle().
    generated_path_table <- td_path_generator_out %>% extract2(1) %>% copy_to(con, df = .)

    td_path_summarizer_out2 <- td_path_summarizer_mle(object = generated_path_table,
                                                  object.partition.column = c('prefix'),
                                                  seq.column = 'sequence',
                                                  partition.names = 'prefix',
                                                  prefix.column = 'prefix'
                                                )