cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
New to using JMP? Hit the ground running with the Early User Edition of Discovery Summit. Register now, free of charge.
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
fionaweston
Level III

How to find tool that processed max number of cells in batch and place that tool ID in a new column.

I have batches of cells that mostly get processed on one alignment tool. Occasionally a batch will be processed over a few alignment tools.

I want to find the tool that processed the maximum number of cells in a batch and then add a column (MAX AL)at the end with that alignment tool ID.

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How to find tool that processed max number of cells in batch and place that tool ID in a new column.

One option

Names Default To Here(1);

dt = Open("$DOWNLOADS/ALIGNMENT TOOL.jmp");

// Get AL cols
al_cols = Filter Each({col_name}, dt << Get Column Names("String"), 
	!IsMissing(Regex(col_name, "^AL\d+"));
);

// create new collector column
new_col = dt << New Column("MAX AL", Character, Nominal);

For Each Row(dt,
	max_al_idx = Loc Max(dt[Row(), al_cols]); // get idx based on max value
	al_name = al_cols[max_al_idx]; // find AL name with the idx
	new_col[Row()] = al_name; // set value
)
-Jarmo

View solution in original post

2 REPLIES 2
fionaweston
Level III

Re: How to find tool that processed max number of cells in batch and place that tool ID in a new column.

adding table.

jthi
Super User

Re: How to find tool that processed max number of cells in batch and place that tool ID in a new column.

One option

Names Default To Here(1);

dt = Open("$DOWNLOADS/ALIGNMENT TOOL.jmp");

// Get AL cols
al_cols = Filter Each({col_name}, dt << Get Column Names("String"), 
	!IsMissing(Regex(col_name, "^AL\d+"));
);

// create new collector column
new_col = dt << New Column("MAX AL", Character, Nominal);

For Each Row(dt,
	max_al_idx = Loc Max(dt[Row(), al_cols]); // get idx based on max value
	al_name = al_cols[max_al_idx]; // find AL name with the idx
	new_col[Row()] = al_name; // set value
)
-Jarmo