Subscribe Bookmark RSS Feed

Send JMP Column Names to R

ValarieSimmons

Community Trekker

Joined:

Mar 2, 2016

Hi all,

I am looking for a solution to send column names that I have retrieved from JMP to send to R.

My codes are as shown below:


Set Environment Variable("R_HOME", "C:\Program Files\R\R-3.3.1\");

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

col = dt<<get column names(string);

Currently the output I obtain from my codes contains curly brackets {}:

From what I understand, R language recognises contents in this format (without { }):

variable <- c("name", "age", "sex", "height", "weight")


Does anyone know how can I remove { } from col in JMP scripting language so that I can send and call it in R environment?

Thank you.

Best Regards,

Val

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson

Super User

Joined:

Jun 22, 2012

Solution

Val,

You can send the list directly to R with

R Send(col);

It will be passed to R as a list, which can be used much like the vector you are trying to  build;  If you then did:

R Submit("\[

Print(col[2]);

]\");

will print the second element of the list col, which is "Age".

So what I am saying, is that you can pass the data easily to R, you just have to work with it as a list, and not as a vector.

But if you really want it as a vector, you can build that vector code as a literal string and pass it to R with an R Submit, by using the following:

     R Submit( "zappy<-c(" || substr(char(col),2,length(char(col))-2) || ");" );

Jim
1 REPLY
txnelson

Super User

Joined:

Jun 22, 2012

Solution

Val,

You can send the list directly to R with

R Send(col);

It will be passed to R as a list, which can be used much like the vector you are trying to  build;  If you then did:

R Submit("\[

Print(col[2]);

]\");

will print the second element of the list col, which is "Age".

So what I am saying, is that you can pass the data easily to R, you just have to work with it as a list, and not as a vector.

But if you really want it as a vector, you can build that vector code as a literal string and pass it to R with an R Submit, by using the following:

     R Submit( "zappy<-c(" || substr(char(col),2,length(char(col))-2) || ");" );

Jim