I have attached example data from which I need to extract the row for which the yield is minimum for a given PartID. I would like to do this using a script.
This I need to do for each PartID and then have a table with only the filtered rows (i.e. [PartID], [Parameter] [(min-) Yeild]).
Note, I have deliberately put identical yield for part C as I may have similar data and would like to handle such using the script. I am on JMP13.
Thanks.
Ok figured it out, the corrected script is (it should be theMin = Minimum( :Yield) inside the for loop as well)
Names Default To Here( 1 );
dt = Current Data Table();
Summarize( dt, thePartID = by( :PartID ), theMin = Minimum( :Yield) );
dt << clear select;
For( i = 1, i <= N Items( thePartID ), i++,
dt << select where(
:PartID == thePartID[i] & :Yield == theMin[i],
current selection( "extend" )
)
);
dtSelected = dt << subset( selected rows(1), selected columns(0));
Here is one way to handle your request:
Names Default To Here( 1 );
dt = Current Data Table();
Summarize( dt, thePartID = by( :PartID ), theMin = Minimum( :Parameter ) );
dt << clear select;
For( i = 1, i <= N Items( thePartID ), i++,
dt << select where(
:PartID == thePartID[i] & :Parameter == theMin[i],
current selection( "extend" )
)
);
dtSelected = dt << subset( selected rows(1), selected columns(0));
Thanks. Running your script directly gives me the following error
Column Must be Numeric in access or evaluation of 'Parameter' , :Parameter/*###*/
In the following script, error marked by /*###*/
dt = Current Data Table();
Summarize( dt, thePartID = by( :PartID ), theMin = Minimum( :Parameter/*###*/ ) );
dt << clear select;
For( i = 1, i <= N Items( thePartID ), i++,
dt << select where(
:PartID == thePartID[i] & :Parameter == theMin[i],
current selection( "extend" )
)
);
dtSelected = dt << subset( selected rows( 1 ), selected columns( 0 ) );
Perhaps the third line should be
Summarize( dt, thePartID = by( :PartID ), theMin = Minimum( :Yield) );Anyway running the script give me with the above line.
Empty()I have attached the data table with script inside.
Ok figured it out, the corrected script is (it should be theMin = Minimum( :Yield) inside the for loop as well)
Names Default To Here( 1 );
dt = Current Data Table();
Summarize( dt, thePartID = by( :PartID ), theMin = Minimum( :Yield) );
dt << clear select;
For( i = 1, i <= N Items( thePartID ), i++,
dt << select where(
:PartID == thePartID[i] & :Yield == theMin[i],
current selection( "extend" )
)
);
dtSelected = dt << subset( selected rows(1), selected columns(0));
Sorry for the misdirection......I made up a data table to test the script on, and in error, I used the :Parameter name as the target column, instead of the :Yield column.