DataObject.CreateFromR

Prototypes

static DataObject CreateFromR( String sName, String sRExpr )

Return Value

The return value is a reference to the newly created object of the DataObject class.

Parameters

String sName
The name to assign to the DataObject.

String sRExpr
An R expression that is evaluated and then coerced to a data frame.

Remarks

This method creates an object of the DataObject class from the result of evaluating an R expression. The method evaluates the R expression, coerces the result to an R data frame, and creates an object of the DataObject class from the variables of the R data frame.

The names of the variables in the DataObject are derived from the names of the variables in the R data frame. Because SAS has different variable naming rules from R, IMLPlus applies the following transformations to convert an R variable name to a valid SAS variable name:

  1. If the name is longer than 32 characters, it is truncated to 32 characters.
  2. If the first character is not valid for a SAS variable name, the character is replaced with '_'. A SAS variable name must begin with one of the following characters: 'A'-'Z', 'a'-'z', or '_'.
  3. If any of the remaining characters are not valid for a SAS variable name, they are replaced with '_'. A SAS variable name can only contain the following characters: 'A'-'Z', 'a'-'z', '0'-'9', or '_'.
  4. If the resulting name duplicates an existing name, a number is appended to the name to make it unique. If appending the number causes the length of the name to exceed 32 characters, the name is truncated to make room for the number.

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

Example
/* The R package "datasets" contains the data set Titanic,
   which defines the data using the structure function. */
declare DataObject dobj;
dobj = DataObject.CreateFromR( "R_Titanic_Dataset", "Titanic" );
DataTable.Create( dobj ).SetWindowPosition( 50, 0 );