Publication date: 07/08/2024

R Integration Functions

R Connect( <named_arguments> )

Description

Returns the current R connection object. If there is no connection to R, it intializes the R integration interfaces and returns an active R integration interface connection as a scriptable object.

Returns

R scriptable object.

Arguments

Echo(Boolean)

(Optional) Sends all source lines to the JMP log. This option is global. The default value is true.

R Control(Interrupt|Async(Boolean)|Echo(Boolean))

Description

Changes the control options for R.

R Execute( { list of inputs }, { list of outputs }, "rCode", <named_arguments> )

Description

Submit the specified R code to the active global R connection given a list of inputs. On completion, the outputs are returned into the specified list.

Returns

0 if successful; nonzero otherwise.

Arguments

{ list of inputs }

A list of JMP variable names to be sent to R as inputs.

{ list of outputs }

A list of JMP variable names to contain the outputs returned from R.

rCode

A quoted string that contains the R code to submit.

Expand(Boolean)

An optional, Boolean, named argument. Performs an Eval Insert() on the R code before submitting to R.

Echo(Boolean)

An optional, Boolean, named argument. Sends all source lines to the JMP log. This option is global. The default value is true.

Example

Send the JMP variables x and y to R, execute the R statement z <- x * y, and then get the R variable z and return it to JMP.

x = [1 2 3];
y = [4 5 6];
rc = R Execute( {x, y}, {z}, "z <- x * y" );

R Get( variable_name )

Description

Gets the named variable from R to JMP.

Returns

The value of the named variable.

Argument

name

Required. The name of an R variable whose value to return to JMP.

Example

Assume that a matrix named qbx and a data frame named df are present in your R connection.

// get the R variable qbx and placed it into a JMP variable qbx
qbx = R Get( qbx );
 
// get the R variable df and placed it into a JMP data table referenced by df
df = R Get( df );

R Get Graphics( "format" )

Description

Gets the last graphics object written to the R graph display window in the specified format.

Returns

A JMP picture object.

Argument

format

Required. Specifies the graphics format to be used. Valid formats are png, bmp, jpeg, jpg, tiff, tif, and gif.

R Get Version

Description

Returns the version number of R being used with JMP R interfaces.

R Init( named_arguments )

Description

Initializes the R session.

Returns

0 if the initialization is successful; any nonzero value otherwise.

Argument

Echo(Boolean)

(Optional) Sends all source lines to the JMP log. This option is global. The default value is true.

R Is Connected()

Description

Determines whether a connection to R exists.

Returns

1 if connected; 0 otherwise.

Arguments

None.

R JMP Name to R Name( name )

Description

Maps the specified JMP variable name to the corresponding R variable name using R naming rules. Requires an active connection to R.

Argument

name

The name of a JMP variable to be sent to R.

Returns

A quoted string that contains the R name.

R Send( name, <R Name( name )>)

Description

Sends named variables from JMP to R.

Returns

0 if the send is successful; any nonzero value otherwise.

Arguments

name

required. The name of a JMP variable to be sent to R.

R Name(name)

(Optional) You can give the variable that you send to R a different name. For example

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

For data tables only:

Selected(Boolean)

optional, named, Boolean. Send only selected rows from the referenced data table to R.

Excluded(Boolean)

optional, named, Boolean. Send only excluded rows from the referenced data table to R.

Labeled(Boolean)

optional, named, Boolean. Send only labeled rows from the referenced data table to R.

Hidden(Boolean)

optional, named, Boolean. Send only hidden rows from the referenced data table to R.

Colored(Boolean)

optional, named, Boolean. Send only colored rows from the referenced data table to R.

Markered(Boolean)

optional, named, Boolean. Send only markered rows from the referenced data table to R.

Row States(Boolean, <named arguments>)

optional, named. Includes a Boolean argument and optional named arguments. Send row state information from the referenced data table to R by adding an additional data column named “RowState”. Multiple row states are created by adding together individual settings. Here are the individual values:

Selected = 1

Excluded = 2

Hidden = 4

Labeled = 8

Colored = 16

Markered = 32

Here are the named arguments for the Row States() argument:

Colors(Boolean)

optional, named, Boolean. Sends row colors. Adds additional data column named “RowStateColor”.

Markers(Boolean)

optional, named, Boolean. Sends row markers. Adds additional data column named “RowStateMarker”.

Examples

Create a matrix, assign it to X, and send the matrix to R:

X = [1 2 3];
rc = R Send( X );

Open a data table, assign a reference to it (dt), and send the data table, along with its current row states, to R:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
rc = R Send( dt, Row States(1) );

R Send File( "pathname", <R Name("name")>)

Description

Sends the specified data file from JMP to R.

Returns

0 if the send is successful; any nonzero value otherwise.

Arguments

pathname

required. A quoted string that contains a pathname for a file.

R Name(name)

(Optional) You can give the data file that you send to R a different name.

R Submit( "rCode", <named_arguments> )

Description

Submits the specified R code to the active global R connection.

Returns

0 if successful; nonzero otherwise.

Arguments

rCode

A required, quoted string that contains the R code to submit.

Expand(Boolean)

An optional, Boolean, named argument. Performs an Eval Insert() on the R code before submitting to R.

Echo(Boolean)

An optional, Boolean, named argument. Sends all source lines to the JMP log. This option is global. The default value is true.

Async(Boolean)

An optional, Boolean, named argument. If set to true (1), the submit can be canceled either by pressing the ESCAPE key, or by using this message to an R connection: rconn<<Control( Interrupt( 1 ) ). False (0) is the default value.

Example

rc = R Submit("\[
	x <- rnorm(5)
	print(x)
	y <- rnorm(5)
	print(y)
	z = plot(x, y)
]\" );

R Submit File( "pathname" )

Description

Submits statements to R using a file pointed in the specified pathname.

Returns

0 if successful; nonzero otherwise.

Argument

Pathname

A quoted string that contains the pathname to the file that contains the R code to be executed.

R Term()

Description

Terminates the currently active R integration interface.

Returns

Returns 0 if the termination is successful and -1 otherwise.

Arguments

None

Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).