For the latest version of JMP Help, visit JMP.com/help.


Scripting Guide > Extending JMP > Work with R > Troubleshoot Working with R
Publication date: 06/21/2023

Troubleshoot Working with R

Troubleshooting R in JMP includes recording output, converting character vectors, and retaining element names.

Recording Output

On Windows, if you want to record output to the graphics window, send the following R code using R Submit( ).

windows.options( record = TRUE );

Character Vectors

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:

R Init();
X = {"Character", "JMP", "List"};
R Send( X );
 

/* R output is:

[1] "list"

*/

R Submit( "class(X)" );
 

/* Object Y is now a character vector. The R output is:

[1] "character"

*/

R Submit( "Y<-unlist(X)
     class(Y)" );
R Term();

Element Names

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[[1]].

R Init();
R Submit("
	pts <- list(x=cars[,1], y=cars[,2])
	summary(pts)
");
 
JMP_pts = R Get( pts );
 
R Send( JMP_pts );
R Submit("
	Summary( JMP_pts )
");
R Term();
Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).