Choose Language Hide Translation Bar
Highlighted
yvesprairie
Level IV

Send JMP Column Names to R

HI all,

 

Am I the only one having problems with the R JMP name to R name function in JSL? It works fine for simple names but as soon as you have slightly unusual names in JMP (something with a parenthesis or a greek symbol for example), the name that is returned is not at all the same as the name stored in the R dataframe resulting from the R send(data table) command. Are there any easy solution to this problem short of renaming JMP column names to something simpler??

 

Many thanks, Yves

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
yvesprairie
Level IV

Re: Send JMP Column Names to R

Thanks for your solution. In the meantime, I gave gone a different route to solve the problem using associative arrays. Basically, I send the data table to R  and retrieve  whatever columns names  R decided to give them back into JMP. I then build an associative array between the JMP name and the R names. Something like:

 

R Send( dt );

R Submit( "Rnames<-names(dt)" );

RnamesinJMP = R Get( Rnames );

aa = Associative Array( JMPnames, RnamesinJMP );

 

I can then translate any JMP column name into its R equivalent with the <<Get value (JMPname) statement

 

THankgs again, Yves

View solution in original post

2 REPLIES 2
Highlighted
ih
ih
Level VII

Re: Send JMP Column Names to R

You are not the only one; here is a possible workaround:

Names default to here( 1 );

//Send sample data to R
dt = New Table( "Original", 
	Add Rows( 2 ),
	New Column( "Hello (there)",
		Numeric, "Continuous", Format( "Best", 12 ),
		Set Values( [1, 2, 3] )
	),
	New Column( "╓ < Greek", Character, "Nominal", Set Values( {"a", "b", "c"} ) )
);
R Init();
R Send(dt);

//Get column names and send them to R
cn = dt << get column names( String );
R Send(cn);

//Set column names
R Submit( "colnames(dt) = cn" );

//Names might not appear to match
R Submit( "print(dt)" ); 

//But they should return correctly
dtr = R Get(dt) << NewDataView;
dtr << Set name("Returned"); 

R Term();
Highlighted
yvesprairie
Level IV

Re: Send JMP Column Names to R

Thanks for your solution. In the meantime, I gave gone a different route to solve the problem using associative arrays. Basically, I send the data table to R  and retrieve  whatever columns names  R decided to give them back into JMP. I then build an associative array between the JMP name and the R names. Something like:

 

R Send( dt );

R Submit( "Rnames<-names(dt)" );

RnamesinJMP = R Get( Rnames );

aa = Associative Array( JMPnames, RnamesinJMP );

 

I can then translate any JMP column name into its R equivalent with the <<Get value (JMPname) statement

 

THankgs again, Yves

View solution in original post

Article Labels

    There are no labels assigned to this post.