#NEWLINE# def _test_main( ) : #NEWLINE# #INDENT# import os #NEWLINE# import readline #NEWLINE# import atexit #NEWLINE# histfile = os . path . join ( os . environ [ 'HOME' ] , '.pyhistory' ) #NEWLINE# try : #NEWLINE# #INDENT# readline . read_history_file ( histfile ) #NEWLINE# #UNINDENT# except IOError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# atexit . register ( readline . write_history_file , histfile ) #NEWLINE# conn = connect ( ) #NEWLINE# print ( '"conn" is your handle to rserve. Type e.g. "conn(\'1\')" for string evaluation.' ) #NEWLINE# sc = open ( '../testData/test-script.R' ) . read ( ) #NEWLINE# v = conn . r ( sc ) #NEWLINE# open ( 'r-test-png.png' , 'w' ) . write ( v [ 3 ] ) #NEWLINE# conn . r . v = 'abc' #NEWLINE# conn . r ( 'func0 <- function() { 3 }' ) #NEWLINE# conn . r ( 'func1 <- function(a1) { a1 }' ) #NEWLINE# conn . r ( 'func2 <- function(a1, a2) { list(a1, a2) }' ) #NEWLINE# conn . r ( 'funcKW <- function(a1=1, a2=4) { list(a1, a2) }' ) #NEWLINE# conn . r ( 'squared<-function(t) t^2' )