R.SubmitStatements

Prototypes

static void SubmitStatements( Matrix mStatements )

static void SubmitStatements( String sStatements )

static void SubmitStatements( String[] asStatements )

Parameters

Matrix mStatements
A character matrix in the shape of a vector in which each element contains R language statements you want to submit to R for execution.

String sStatements
A string containing R language statements you want to submit to R for execution. The string may contain newline characters ('\n'). IMLPlus does not impose a limit to the length of the string.

String[] asStatements
An array of strings in which each string contains R language statements you want to submit to R for execution. The individual strings may contain newline characters ('\n'). IMLPlus does not impose a limit to the length of the strings.

Remarks

This method submits R language statements to R for execution.

Because all the elements in an IML character matrix are stored with a common length, individual entries may be padded with trailing spaces. For the matrix form of this method, IMLPlus strips off trailing spaces from each matrix element before submitting the statements to R. If the technique of storing R language statements in an IML character matrix causes a problem with a particular sequence of R statements, use one of the other forms of this method.

A sequence of R language statements that is submitted to R by an IMLPlus program must contain zero or more complete R statements or expressions. IMLPlus does not support submitting partial R statements or expressions.

IMLPlus provides a very convenient shortcut for calling the SubmitStatements method: the SUBMIT statement with the /R option. When IMLPlus encounters a SUBMIT statement with the /R option, it passes the program source code between the SUBMIT statement and the following ENDSUBMIT statement to the method R.SubmitStatements. (Note that it is still necessary to call the method R.SubmitStatements directly in situations where the IMLPlus program builds R language statements dynamically.)

Example
declare DataObject dobj = DataObject.CreateFromFile( "Baseball" );

dobj.ExportToR( "df" );

R.SubmitStatements( "fm <- lm( no_home ~ no_hits, data=df )" );

dobj.AddAnalysisVarFromR( "Fit", "fitted(fm)" );

declare ScatterPlot plot;
plot = ScatterPlot.Create( dobj, "no_hits", "no_home" );
dobj.GetVarData( "no_hits", x );
dobj.GetVarData( "Fit", fit );
plot.DrawUseDataCoordinates();
plot.DrawSetPenColor( RED );
plot.DrawLine( x, fit );