Note: For Windows, R version 2.13.0 - 3.0.0 and higher have been tested and verified as compatible with JMP and JMP Pro version 11. For Macintosh OS X, only R version 2.13.0 - 2.15.3 have been tested and verified as compatible with JMP and JMP Pro version 11; neither JMP nor JMP Pro version 11 supports R version 3.0.0 and higher on Macintosh OS X.
Install R on the same computer as JMP. You can download R from the Comprehensive R Archive Network website:
Because JMP is supported as both a 32-bit and a 64-bit Windows application, you must install the corresponding 32-bit or 64-bit version of R. For the supported version of R, see the system requirements on the JMP website:
JMP delays loading R until a JSL-based script requires access to it. When JMP needs to load R, it follows the standard steps for finding R on a Windows computer:
Look up the environment variable R_HOME.
If the environment variable R_HOME does not exist, look up the InstallPath value in the Windows registry under the following key:
For 32-bit JMP running on a 64-bit machine, the InstallPath value is under the following key:
If the InstallPath value exists, load R from the specified directory.
If the InstallPath value does not exist, an error message states that R could not be found.
To test that your computer is able to run JSL-based scripts that use R, run the following JSL script:
The following JMP interfaces are provided to access R. The basic execution model is to first initialize the R connection, perform the required R operations, and then terminate the R connection. In most cases, these functions return 0 if the R operation was successful, or an error code if it was not. If the R operation is not successful, a message is written to the log. The single exception to this is R Get( ), which returns a value.
The R interfaces are also scriptable using an R connection object. A scriptable R connection object can be obtained using the R Connect() JSL function.
Equivalencies Between JMP and R Data Types for R Send( ) 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.
Equivalencies Between JMP and R Data Types for R Get( ) 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.
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:
For example, sending nsref:dt to R creates a corresponding R object named nsref.dt.
For example, sending ::dt to R creates a corresponding R object named dt.
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:
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.
/*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.*/
On Windows, if you want to record output to the graphics window, send the following R code using R Submit( ).
A JMP list of strings is not the same as an R character vector. If you send a list of strings to R, it becomes a list of strings in R, not a character vector. You can use the R function Unlist to convert it:
A feature of an R list (called attributes) lets you associate a name with each element of the list. You can use the name to access that element instead of having to know the position of it in the list
In the following example, the list that is created in R has two elements named x and y that are created using the List() function of R. When your bring the R list into JMP and then send it back to R, the names are lost. Therefore in R, you cannot access the first matrix using pts$x. Instead, you must use the index using pts[].
This example initiates an R connection, sends a data table to R, prints it to the log, and closes the R connection.
This example initiates an R connection, creates an R object, retrieves the object into JMP, and closes the R connection.
This example initiates an R connection and plots the normal density function in R using the R graphics device,. Then the graph is retrieved from R and displayed in JMP. Finally, the R connection is closed.
This example initiates an R connection, sends a matrix to R, creates a matrix in R, adds them together, returns the new matrix to JMP, and closes the R connection.
See the file JMPtoR_bootstrap.jsl in the sample scripts folder for an example script.
The script produces a JMP window that asked the user to specify the variable to perform bootstrapping over. Then the user selects a statistic to compute for each bootstrap sample. Finally, the data is sent to R using the R interface in JSL.
The boot package in R is used to call the boot() function and the boot.ci() function to calculate the sample statistic for each bootstrap sample and the bootstrap confidence interval.