BookmarkSubscribeRSS Feed
Choose Language Hide Translation Bar
Thierry_S

Not applicable

Joined:

Apr 19, 2018

Help Locating a Column Header Editing Utility Tools?

Hi JMP Community,

 

I have been looking without success for an utility add-in that would simplify and expedite the management of column names in JMP 13.1.

 

Ideally, this utility add-in would perform the following:

  1. Add a prefix and/or suffix to selected existing column names
  2. Rename a set of selected target columns based on the names of selected sources columns; adding a prefix and/or a suffix
    1. Example: input
      1. Source columns = Protein 1, Protein 2, Protein 3
      2. Target columns = Column 4, Column 5, Column 6
      3. Prefix = "Log10 "
    2. Output:
      1. Target columns = Log10 Protein 1, Log10 Protein 2, Log10 Protein 3

My JSL skills being pretty limited, I would greatly appreciate receiving your feedback about potential existing add-in or about JSL code that would achieve these 2 functions.

 

Thank you,

 

TS

Thierry R. Sornasse
2 ACCEPTED SOLUTIONS

Accepted Solutions
uday_guntupalli

Community Trekker

Joined:

Sep 15, 2014

Solution

Re: Help Locating a Column Header Editing Utility Tools?

@Thierry_S , 
      I don't know of add-ins, but maybe try something like this : 

 

cleaner = function({collist,flag,tag},{default local},
		    newcollist = {}; 
		    If(flag == "prefix",
		       for(i = 1, i <= N items(collist), i++,
			   Insert Into(newcollist,tag || collist[i]);
			  );
			,
			// else 
			If(flag == "postfix",
			   for(i = 1, i <= N items(collist), i++,
				Insert Into(newcollist, collist[i] || tag);
			      );
			  );     
		      ); 
    		      return(newcollist); 
		   ); 

/* Demo */ 
collist = {"Protein 1","Protein 2","Protein 3"};
tag = "Log10"; 
flag = "prefix"; 

// Prefix 
PrefixExample = cleaner(collist,flag,tag); 
Show(PrefixExample);

// Postfix
flag = "postfix";
PostfixExample = cleaner(collist,flag,tag); 
Show(PostfixExample);

 In order to retrieve the column names as a list from a data table, you can do the following: 

 

ColNamesAsList = dt << Get Column Names("String"); // Assuming dt is a reference to the data table 
Best
Uday
Highlighted
txnelson

Super User

Joined:

Jun 22, 2012

Solution

Re: Help Locating a Column Header Editing Utility Tools?

When you look into the Scripting Index for a specific function or object, you will see listed, all of the various messages that can be used to manipulate or retrieve items from it.  Below is a simple expansion of the Col List Box() 3rd example that retrieves the items from the selected Col List Box(), "ll2" and then places them into the code that will run the Distribution Platform, for each of the selected columns.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
New Window( "Col List Box Example 3",
	H List Box(
		ll1 = Col List Box( all ),
		Button Box( "Add", ll2 << append( ll1 << get selected ) ),
		ll2 = Col List Box( "numeric", nlines( 5 ) ),
		Button Box( "Remove", ll2 << remove selected ), 
		
		Button Box( "Run Selected",
			x = ll2 << get items;
			For( i = 1, i <= N Items( x ), i++,
				Distribution( Continuous Distribution( Column( x[i] ) ) )
			)
		)
	)
);
Jim
5 REPLIES 5
uday_guntupalli

Community Trekker

Joined:

Sep 15, 2014

Solution

Re: Help Locating a Column Header Editing Utility Tools?

@Thierry_S , 
      I don't know of add-ins, but maybe try something like this : 

 

cleaner = function({collist,flag,tag},{default local},
		    newcollist = {}; 
		    If(flag == "prefix",
		       for(i = 1, i <= N items(collist), i++,
			   Insert Into(newcollist,tag || collist[i]);
			  );
			,
			// else 
			If(flag == "postfix",
			   for(i = 1, i <= N items(collist), i++,
				Insert Into(newcollist, collist[i] || tag);
			      );
			  );     
		      ); 
    		      return(newcollist); 
		   ); 

/* Demo */ 
collist = {"Protein 1","Protein 2","Protein 3"};
tag = "Log10"; 
flag = "prefix"; 

// Prefix 
PrefixExample = cleaner(collist,flag,tag); 
Show(PrefixExample);

// Postfix
flag = "postfix";
PostfixExample = cleaner(collist,flag,tag); 
Show(PostfixExample);

 In order to retrieve the column names as a list from a data table, you can do the following: 

 

ColNamesAsList = dt << Get Column Names("String"); // Assuming dt is a reference to the data table 
Best
Uday
Thierry_S

Not applicable

Joined:

Apr 19, 2018

Re: Help Locating a Column Header Editing Utility Tools?

Hi Uday,

That's a good start that could work well with some kind of interface that would allow the selection the Source and Target columns

Thanks
Thierry R. Sornasse
txnelson

Super User

Joined:

Jun 22, 2012

Re: Help Locating a Column Header Editing Utility Tools?

I suggest that you take the code that Uday provided you as a good start for You to put a Col List Box() in front of and for You to create the tool you need.  Documentation on the Col List Box() can be found in the Scripting Guide, or in the Scripting Index.

     Help==>Books==>Scripting Guide

     Help==>Scripting Index

Jim
Thierry_S

Not applicable

Joined:

Apr 19, 2018

Re: Help Locating a Column Header Editing Utility Tools?

Hi TxNelson,

 

Thanks for your recommendation. I spent a couple of hours experimenting with the Col List Box() function but I cannot figure out how to get the list of selected columns out to then feed into Uday's script.

 

Sorry for not being proficient in JSL.

 

Thank you for your help.

TS 

Thierry R. Sornasse
Highlighted
txnelson

Super User

Joined:

Jun 22, 2012

Solution

Re: Help Locating a Column Header Editing Utility Tools?

When you look into the Scripting Index for a specific function or object, you will see listed, all of the various messages that can be used to manipulate or retrieve items from it.  Below is a simple expansion of the Col List Box() 3rd example that retrieves the items from the selected Col List Box(), "ll2" and then places them into the code that will run the Distribution Platform, for each of the selected columns.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
New Window( "Col List Box Example 3",
	H List Box(
		ll1 = Col List Box( all ),
		Button Box( "Add", ll2 << append( ll1 << get selected ) ),
		ll2 = Col List Box( "numeric", nlines( 5 ) ),
		Button Box( "Remove", ll2 << remove selected ), 
		
		Button Box( "Run Selected",
			x = ll2 << get items;
			For( i = 1, i <= N Items( x ), i++,
				Distribution( Continuous Distribution( Column( x[i] ) ) )
			)
		)
	)
);
Jim