cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Aam_jmp
Level IV

Working with matching values from lists to tables

I have two lists extracted from a data set, one list contains column names and another, certain values extracted (one value from each column) based on certain conditions.

List1 = {Wweight, O2 Uptake.......};

List2 = {38,59.08.....};
After this step, the user gets a JMP table like the one below as an output with options whether to remove the value extracted by the script or not:

Capture.PNG

 

 

 

The user either removes the value from the main table or decides to keep it.
What I am further trying to do is:
1) I run a script to find minimum values, and if the value matches the value against that column (which means that the user decided to keep the value) I want to get the next minimum value
2) If not, I extract the minimum value as is.

 

dt = current data table();

colNamesList = dt << get column names( string, numeric, continuous );
nc = N Items( colNamesList );

Names = {};
MinVals = {};
MinValList = {};

For( i = 1, i <= nc, i++,
	Cols = Column( dt, i );

	Insert into(Names, colNamesList[i]);
	MinValue = Col Min( Cols );
	Insert into(MinVals, MinValue);
	MinRows = dt << get rows where( As Column( Cols ) == MinValue );
	Insert into(MinValList, MinRows[1]);
	);
	
	

dt1 = new table( "Data", 
	New Column( "Column Name", character, nominal, values(Names)),
	New column( "Min value", numeric, nominal, values( MinVals)),
	New Column( "Row Number", expression, nominal, values( MinValList ));
	
);

How can I match the values to check for each row whether the user has removed the value or not? 

//Second Part

For( i = 1, i <= nc, i++,
	Cols = Column( dt, i );
	colMin = Col Min( Cols );
	//If value in Col min is equal to value in MinValue, then skip that value and choose the next minimum value, else add that value to a new list
4 REPLIES 4
cwillden
Super User (Alumni)

Re: Working with matching values from lists to tables

You could do something like this:

For( i = 1, i <= nc, i++,
	Cols = Column( dt, i );
	colMin = Col Min( Cols );
	//If value in Col min is equal to value in MinValue, 
	//then skip that value and choose the next minimum value, else add that value to a new list
	
	//get the corresponding row in the table (if it doesn't align with the index of your loop)
	row_tmp = dt1 << Get Rows Where(:Column Name == Cols); 
	if(Min value[row_tmp] == colMin,
		//Insert Code to look for next smallest value
	)
)

row_tmp gets the row in dt1 where the value of Column Name matches the current column name in Cols.

-- Cameron Willden
Aam_jmp
Level IV

Re: Working with matching values from lists to tables

@cwillden

Capture.PNG

I get this output for row_tmp

cwillden
Super User (Alumni)

Re: Working with matching values from lists to tables

I probably should have included a "[1]" on the end of that definition for row_temp. Sorry, I'm shooting from the hip a bit here without actually running this through JMP with an example data table.  Make sure to wrap the whole thing in parentheses before adding the [1].

(row_tmp <span class="token operator">=</span> dt1 <span class="token operator"><</span><span class="token operator"><</span><span class="token messages"> Get Rows Where</span><span class="token punctuation">(</span><span class="token punctuation">:</span>Column Name <span class="token operator">==</span> Cols<span class="token punctuation">))[1]</span><span class="token punctuation">;</span> 

 You probably are also comparing to a name object rather than a string.  To get the column name as a string, try this:

Cols = Column(dt, 1) << Get Name;

I think with both of those changes, it should work.

-- Cameron Willden
Aam_jmp
Level IV

Re: Working with matching values from lists to tables

@cwillden I'm sorry, it still doesn't work for me. I just want to check if Min Values are still present in the columns of Linnerud table. But I am unable to make that script to work.