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
lala
Level VIII

How to use JMP software JSL to efficiently find the minimum value?

How to use JMP software JSL to efficiently find the minimum value in the same row, multiple columns, and the rank of the column in which the minimum value resides.

 

dt = Open( "$SAMPLE_DATA/PopAgeGroup.jmp" );
New Column( "mi" );
New Column( "ix" );
Column( "mi" ) << Formula( ? );
dt << run formulas;
Column( "mi" ) << deleteFormula;
Column( "ix" ) << Formula( ? );
dt << run formulas;
Column( "ix" ) << deleteFormula;

2023-07-17_10-38-52.png

3 REPLIES 3
lala
Level VIII

回复: How to use JMP software JSL to efficiently find the minimum value?

Thanks!

Column( "mi" ) << Formula(r=row();min( dt[r,8::13]) );
Column( "ix" ) << Formula(r=row();contains(dt[r,8::13],min( dt[r,8::13]) ));
txnelson
Super User

Re: How to use JMP software JSL to efficiently find the minimum value?

Is this what you are looking for

dtsub << New Column( "mi",
	set each value( Min( dtsub[Row(), 8 :: 13] ) )
);

dtsub << New Column( "ix",
	set each value(
		theList = dtsub[Row(), 8 :: 13];
		val = Loc( theList, Min( theList ) );
	)
);
Jim
jthi
Super User

Re: How to use JMP software JSL to efficiently find the minimum value?

First get the indices or names of the columns you wish to find the values from and then either use Min to get minimum value and Loc() to find the value OR use Loc Min() to find index and then that index to find the minimum value. Below is example using Loc Min to get index and then the value

Names Default To Here(1);

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

// get either index or name of columns of interest
cols_of_interest = Filter Each({col_name}, dt << Get Column Names(Continuous, "String"),
	!IsMissing(Regex(col_name, "^(Portion|F Rate).*[\d+]$"))
);

dt << New Column("MinIdx", Numeric, Continuous, << Set Each Value(
	Loc Min(dt[Row(), cols_of_interest])
));

dt << New Column("MinVal", Numeric, Continuous, << Set Each Value(
	dt[Row(), cols_of_interest[:MinIdx]]
));

Also if you have no need for formulas, it is better to not use them and rather use << Set Each Value.

-Jarmo