Scripting Guide > Extending JMP > Work with R > Conversion Between JMP Data Types and R Data Types
Publication date: 08/13/2020

Conversion Between JMP Data Types and R Data Types

Table 14.3 shows what JMP data types can be exchanged with R using the R Send( ) function. Sending lists to R recursively examines each element of the list and sends each base JMP data type. Nested lists are supported.

Table 14.3 Equivalent JMP and R Data Types for R Send( )

R Data Type

JMP Data Type

Double

Numeric

String

String

Double Matrix

Matrix

List

List

Data Frame

Data Table

Integer

Row State

Date and Time

Datetime

Time/Duration

Duration

Paired List

Associative Array

Example

R Init();
X = 1;
R Send( X );
S = "Report Title";
R Send( S );
M = [1 2 3, 4 5 6, 7 8 9];
R Send( M );
R Submit( "
X
S
M
" );
R Term();

Table 14.4 shows what JMP data types can be exchanged with R using the R Get() function. Getting lists from R recursively examines each element of the list and sends each base R data type. Nested lists are supported.

Table 14.4 Equivalent JMP and R Data Types for R Get( )

R Data Type

JMP Data Type

Double

Numeric

Logical (Boolean)

Numeric ( 0 | 1 )

String

String

Integer

Numeric

Date and Time

Datetime

Time/Duration

Duration

Factor

Expanded to a list of Strings or a Numeric matrix

Data Frame

Data Table

List

List of converted R data types

Matrix

Numeric Matrix

Numeric Vector

Numeric Matrix

String Vector

List of Strings

Graph

Picture

Time Series

Matrix

Paired List

Associative Array

JMP Scoping Operators and R

A JMP object sent to R using R Send() uses the same JMP reference as the name of the R object that gets created. For example, sending the JMP variable dt to R creates an R object named dt. The colon and double colon scoping operators (: and ::) are not valid in R object names, so these are converted as follows:

A single colon scoping operator is replaced with a period (.).

For example, sending nsref:dt to R creates a corresponding R object named nsref.dt.

A double colon scoping operator (designating a global variable) is ignored.

For example, sending ::dt to R creates a corresponding R object named dt.

Using R Name() with R Send()

The R Name() option to R Send() has an argument that is a quoted string that contains a valid R object name. The JMP object sent to R becomes an R object with the name specified. For example:

R Send( jmp_var_name, R Name( "r_var_name") );
R Submit( "print(r_var_name)" )

Example

This example creates a variable x in the Here namespace, a variable y in the global namespace, and a variable z that is not explicitly referenced to any namespace. The variable z defaults to Global unless Names Default To Here(1) is on. These variables are then passed to R.

Here:x = 1;
::y = 2;
z = 3;
 
R Init(); // initiate the R connection
 

/* send the Here variable to R

Here:x creates the R object Here.x */

R Send( Here:x );
 

/* note that the JMP log labels the output with the original JMP variable reference Here:x */

R Submit( "print(Here.x)" );
 
R Send( ::y ); // ::y create the R object y
R Submit( "print(y)" );
 

// to use a different name for the R object, use the R Name() option

R Send( Here:x, R Name( "localx" ) );
 

/* The R Name option to the R Send() command creates the R object named "localx"" corresponding to the JMP variable "Here:x". Again the log shows the original corresponding JMP variable name. */

R Submit( "print(localx)" );
R Send( z ); // z creates the R object z
R Submit( "print(z)" );
Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).
.