14.03.2014 Views

Scripting Guide - SAS

Scripting Guide - SAS

Scripting Guide - SAS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

490 Extending JMP Chapter 14<br />

Working with R<br />

Using R Name() with R Send()<br />

The R Name() option to R Send() has an argument that is a quoted string that contains a valid R object<br />

name. The JMP object sent to R becomes an R object with the name specified. For example:<br />

R Send( jmp_var_name, R Name( "r_var_name") );<br />

R Submit( "print(r_var_name") )<br />

Example<br />

This example creates a variable x in the Here namespace, a variable y in the global namespace, and a<br />

variable z that is not explicitly referenced to any namespace. The variable z defaults to Global unless Names<br />

Default To Here(1) is on. These variables are then passed to R.<br />

Here:x = 1;<br />

::y = 2;<br />

z = 3;<br />

//Initiate the R connection<br />

R Init();<br />

//Send the Here variable to R<br />

//Here:x creates the R object Here.x"<br />

R Send( Here:x );<br />

R Submit( "print(Here.x)" );<br />

/* Note that the JMP log labels the output with the original JMP variable<br />

reference Here:x. */<br />

//::y creates the R object y<br />

R Send( ::y );<br />

R Submit( "print(y)" );<br />

//To use a different name for the R object, use the R Name() option<br />

R Send( Here:x, R Name( "localx" ) );<br />

R Submit( "print(localx)" );<br />

/*The R Name option to the R Send() command creates the R object named<br />

"localx"" corresponding to the JMP variable "Here:x". Again the log shows<br />

the original corresponding JMP variable name.*/<br />

//z creates the R object z<br />

R Send( z );<br />

R Submit( "print(z)" );<br />

Troubleshooting<br />

Recording Output<br />

On Windows, if you want to record output to the graphics window, send the following R code using R<br />

Submit( ).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!