Writing R Scripts for Aster - 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

Communication between the R program and the Aster Database is through standard input and output (STDIN and STDOUT). An R script for use with the Aster Database should read rows from STDIN as input and write output to STDOUT.

A sample framework is shown here.

#File descriptor pointing to standard input
in_table = file(description="stdin",open="r") 

# Read column values from stdin into a vector, nrows = -1 means read all rows
while(1){ 
    fields<-try(read.table(in_table,header=FALSE,sep="\t",quote="",nrows=-1) silent=TRUE ) 
    if(inherits(fields,"try-error"))   
    break   

    < data processing lines go here >  
    
    out_data<-data.frame(< columns of output data frame defined here > ) 

#write to standard output stream 
    write.table(out_data, stdout(),col.names=FALSE,row.names=FALSE,quote=FALSE,sep="\t")
}
# END

If an R script uses functions from the Aster R package, then the TeradataAsterR package must be installed on the Aster cluster.

Refer to Appendix C Installing TeradataAsterR Package on the Aster Cluster for information on how to install the TeradataAsterR package on the Aster cluster.