DataObject.AddVarFromR

Prototypes

void AddVarFromR( String sVarName <, String sVarLabel>, String sRExpr )

Parameters

String sVarName
The name for the new variable. This string must be a valid SAS variable name.

String sVarLabel
The label for the new variable. This string can be used to describe the variable. If the sVarLabel parameter is not specified, the variable is assigned a label that is the same as its name.

String sRExpr
An R expression that is evaluated and then coerced to a data frame. Only the first variable within the data frame is used.

Remarks

This method adds a variable to the DataObject using the result of evaluating an R expression. The method evaluates the R expression, coerces the result to an R data frame, and adds the first variable of the data frame to the DataObject. The names of the variables in the R data frame are ignored.

For information about how IML Studio transfers data from R to IMLPlus, please refer to the topic Data Exchange Details.

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

dobj.ExportToR( "df" );
dobj.AddVarFromR( "Fit", "fitted( lm( no_home ~ no_hits, data=df ) )" );

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 );
See Also

DataObject.AddAnalysisVarFromR
DataObject.AddAnalysisVarsFromR
DataObject.AddVarsFromR