Example of Running an R Script using Aster Stream - Aster R

Teradata Aster® R User GuideUpdate 3

Product
Aster R
Release Number
7.00.02.01
Published
December 2017
Language
English (United States)
Last Update
2018-04-13
dita:mapPath
fop1497542774450.ditamap
dita:ditavalPath
Generic_no_ie_no_tempfilter.ditaval
dita:id
fbp1477004286096
lifecycle
previous
Product Category
Software
This example uses the same input as in Example 3: Custom R Function. Users must make sure that the Input table is in the Aster Database and is named "fruit".

This example uses the same R script as in Example 1: Simple Calculation.

  1. Retrieve content from the input table "fruit".
    select * from fruit;
  2. Install the R script on the cluster.
    \install fruit_1104b.R
  3. Run the Stream function call.
    • Users can run the Stream function call directly, and the output is shown on the screen.
      select * from stream (on fruit 
      script('Rexec --vanilla fruit_1104b.R') 
      outputs('SaleDate varchar', 'DailySales numeric','DailyProfit numeric') 
      delimiter('\t') 
      );
      
       SaleDate | DailySales | DailyProfit 
      ----------+------------+-------------    
       5/1/2010 |       29.8 |        5.65
       5/2/2010 |      31.78 |         6.8
       5/3/2010 |      19.25 |        4.72
       5/4/2010 |      20.57 |        5.72
      (4 rows)
    • Alternatively, users can create a table to save the output in the database, by wrapping the Stream function call in a CREATE TABLE call.
      create dimension table WeeklyTable as
      (select * from stream (on fruit 
      script('Rexec --vanilla fruit_1104b.R') 
      outputs('SaleDate varchar', 'DailySales numeric','DailyProfit numeric') 
      delimiter('\t') 
      ));

      Users can then run the select command to display the result table. The output is the same as the output of running the Stream function call directly.

      select * from WeeklyTable;