7.00.02.01 - Writing R Scripts for Aster - Aster R

Teradata Aster® R User GuideUpdate 3

prodname
Aster R
vrm_release
7.00.02.01
created_date
December 2017
category
Programming Reference
User Guide
featnum
B700-1033-700K

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.