The IMLPlus language and the R language have significant differences in the areas of data types and data structures. This topic describes how IML Studio reconciles these differences. Note that when transferring data from R to IMLPlus, IML Studio performs all the relevant conversion steps described in this topic regardless of whether the destination is a SAS data set or an IML matrix.
R can store numeric data in either integer format or double precision format. IMLPlus stores all numeric matrices in double precision format. The IMLPlus DataObject class also stores all numeric data in double precision format. When IML Studio transfers numeric data from R to IMLPlus, it converts any integer data to double precision format.
Each variable in an IMLPlus DataObject is assigned a measurement level. The measurement level for a numeric variable can be either Interval or Nominal. R does not have the concept of a measurement level for numeric data, but R has factors. When IML Studio transfers a nominal numeric variable from IMLPlus to R, it creates a factor in R. When IML Studio transfers data from R to IMLPlus, it performs the following steps for each variable to convert factors appropriately:
R provides a data type called logical for storing the values TRUE and FALSE. When IML Studio transfers logical data to IMLPlus, it converts the value TRUE to the number 1 and the value FALSE to the number 0.
IML Studio stores character data internally in Unicode UTF-16 format. When IML Studio transfers character data from IMLPlus to R, it performs the following steps:
When IML Studio transfers character data from R to IMLPlus, it performs the following steps:
R provides two data types that are not supported by the IML Studio interface to R: complex, and raw. IMLPlus does not support either of these data types. If you attempt to transfer data stored in either of these data types to IMLPlus, IML Studio will display an error message.
R supports special numeric values such as infinities and NaNs differently from IMLPlus. For information about how IMLPlus and SAS support special numeric values, please refer to the topic About Infinities and NaNs.
The following table shows how IML Studio converts SAS missing values when transferring data from IMLPlus to R:
SAS Missing Value | Value in R |
---|---|
.I | Inf |
.M | -Inf |
all others | NA |
The following table shows how IML Studio converts special numeric values when transferring data from R to IMLPlus:
Value in R | SAS Missing Value |
---|---|
Inf | .I |
-Inf | .M |
NA | . |
NaN | . |
R supports date and time data differently from IMLPlus. In IMLPlus (and SAS in general), variables are not explicitly tagged as containing date or time data. Instead, such variables are assigned a format (such as DATE9.) that causes the numeric values to be displayed in the desired format. In R, variables are explicitly tagged as containing date or time data. When IML Studio transfers data from IMLPlus to R, it performs the following steps for each variable to convert date and time data:
When IML Studio transfers data from R to IMLPlus, it performs the following steps for each variable to convert date and time data:
In IMLPlus (and SAS in general), the sampling times for time series data are stored in a separate variable. In R, the sampling times for time series data are specified by the tsp attribute of a time series variable. When IML Studio transfers data from R to IMLPlus, it performs the following steps for each variable to preserve the sampling times:
The following IMLPlus program demonstrates how to use time series data imported from R:
declare DataObject dobj = DataObject.CreateFromR( "co2", "co2" ); DataTable.Create( dobj ).SetWindowPosition( 50, 50 ); declare LinePlot plot = LinePlot.Create( dobj, "x_ts", "x" ); plot.ShowPoints( "x", false );
When IML Studio transfers data from IMLPlus to R, it does not perform any special processing related to time series.
R provides a wider range of data structures than IMLPlus (excluding the ability of IMLPlus to use Java data structures and objects). To package all R data into a data structure that is compatible with IMLPlus, IML Studio transfers all data from R to IMLPlus using R data frames. If the R data is not already in the form of a data frame, IML Studio coerces the data to a data frame before transferring it to IMLPlus.