Don't know how to title this but here goes. I have data sets with several time points per batch. For each batch I want to calculate the difference in results from time point zero. I used to compare each result to column min or max (as suitable) which worked fine, but when results are a bit jumpy, the max or min may happen at another time point than zero.
I want the (desired) diff as below. Is there a simple way to do this in a formula?
jmp 17.1
If the results are ordered, you could use something like this:
:Result - :Result[Col Min(Row(), :Batch)]
Col Min(Row(), :Batch) will get the first row for specific batch and then we can access that row by using :Result[rownr].
If the data isn't always ordered it isn't really a problem, but it will require different formula
If the results are ordered, you could use something like this:
:Result - :Result[Col Min(Row(), :Batch)]
Col Min(Row(), :Batch) will get the first row for specific batch and then we can access that row by using :Result[rownr].
If the data isn't always ordered it isn't really a problem, but it will require different formula
Thanks for extremely fast, and useful, response! I will ponder how, but I see it works!
Easiest way (in my opinion) to see how it works is to divide that formula into three different formulas
First one (BatchMinRow)
Col Min(Row(), :Batch)
Second using the just created BatchMinRow (BatchMinVal)
:Result[:BatchMinRow]
and finally third one
:Result - :BatchMinVal
this makes it much easier to see what the different parts in the formula do
Just adding few possible options if the data isn't always sorted.
Using matrix calculations to get the indices
As Constant(
times = :Time << get as matrix;
batches = :Batch << get as matrix;
);
batch_rows = Loc(batches, :Batch);
batch_first_time_row = batch_rows[Loc Min(times[batch_rows])];
:Result - :Result[batch_first_time_row];
and using Col Sum to get the minimum value with comparison and product (if :Time isn't the smallest multiplier is 0).
:Result - Col Sum((:Time == Col Min(:Time, :Batch)) * :Result, :Batch);