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.
-
Retrieve content from the input table "fruit".
select * from fruit;
-
Install the R script on the cluster.
\install fruit_1104b.R
-
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;
- Users can run the Stream function call directly, and the output is shown on the screen.