条件に基づく行間の計算こんにちは。私は JMP スクリプトは初めてですが、Python 言語には多少慣れています。以下のダミー テスト テーブルを使用して、次のことを実現しようとしています。
1) すべての行 (行の前後両方) を循環し、Cuvette == 11 の行に対してのみ計算を実行し、Cuvette != 11 の残りの行に対しては、「出力」を NA などに設定できます。
2) 計算自体は 2 つの別々の行間で行われます。Cuvette == 11 の行では、行の 850 nm セルを、次の 2 つの条件を満たす行の 250 nm セルで割る必要があります。
a) キュベット == 12
b) パス値は行間で一致する必要があります。例: キュベット 11 のパス値 == キュベット 12 のパス値
| 合格 |
850 nm |
250 nm |
キュベット |
出力 |
| 1 |
100 |
200 |
11 |
100/500 = 0,2 |
| 2 |
400 |
500 |
11 |
400 / 400 = 1 |
| 3 |
300 |
100 |
11 |
300 / 900 = 0.33 |
| 1 |
700 |
500 |
12 |
それ |
| 2 |
200 |
400 |
12 |
それ |
| 3 |
400 |
900 |
12 |
それ |
| 1 |
400 |
800 |
13 |
それ |
| 2 |
500 |
700 |
13 |
それ |
| 3 |
300 |
700 |
13 |
それ |
自動化とスクリプト基本的なデータ分析とモデリングRe: 条件に基づく行間の計算JMP のような方法でこれを実行するには、通常、データを分割して計算を実行し ( JMP はスプレッドシートではありません)、その後、データを結合し直すか、分割されたデータで続行します。
ただし、この計算には JSL または Formula を使用することもできますが、まず分割オプションを検討してください。
Re: 条件に基づく行間の計算コミュニティへようこそ。
これは私があなたの問題にどのように取り組むかの例です

Names Default To Here( 1 );
dt = Current Data Table();
// Separate out the Cuvette==12 rows into a separate data table
// and then join the Pass==Pass rows to the Cuvette==11 rows
// Then calculate the Output column
// Select the Cuvette==12 rows
dt << Select Where( :Cuvette == 12 );
// Create a new subsetted data table with those rows
dt12 = dt << Subset( Selected Rows( 1 ), columns( :Pass, :"250 nm"n ) );
// Change 250 nm column name so when joined back to original table
// it will have a unique column name
dt12:"250 nm"n << Set Name( "Divisor" );
// For alignment reasons, add a new column called Cuvette and set
// it equal to 11
dt12 << New Column( "Cuvette", Set Each Value( 11 ) );
// Join the tables using the Update Platform
dt << Update(
With( dt12 ),
Match Columns( :Pass = :Pass, :Cuvette = :Cuvette )
);
// Create the new Output column
dt << New Column( "Output", Set Each Value( :"850 nm"n / :Divisor ) );
// Remove Divisor column since it is no longer needed
dt << delete columns( Divisor );
// Close the subsetted data table since it is no longer needed
Close( dt12, nosave );
// Remove the Selected RowStates from the data table
dt << clear rowstates;
以下はより直接的なアプローチですが、同じ結果をもたらすはるかに非効率的な方法です。大きなデータテーブルでは、この方法は非常に遅くなります。
Names Default To Here( 1 );
dt = Current Data Table();
dt << New Column( "Output",
Formula(
foundRow = [];
If( :Cuvette == 11,
curPass = :Pass;
foundRow = Current Data Table() <<
get rows where( :Cuvette == 12 & :Pass == curPass );
If( N Items( foundRow ) > 0,
:"850 nm"n / :"250 nm"n[foundRow[1]]
);
);
)
);
Re: 条件に基づく行間の計算ここでは1つの行列オプションを示しますが、JMPの機能を使用する方が一般的に理解しやすいです。
Names Default To Here(1);
dt = Current Data Table();
cuvette_start = 11;
cuvette_end = 12;
cuvettes = dt[0, "Cuvette"];
// Data is sorted -> we can just take values and make comparison
start_idx = Loc(cuvettes, cuvette_start);
end_idx = Loc(cuvettes, cuvette_end);
// differences
output = J(1, N Rows(dt), .);
output[start_idx] = dt[start_idx, "850 nm"] :\</img> dt[end_idx, "250 nm"];
dt << new column("R", Numeric, Continuous, Values(output));
順序に大きく依存できる場合は、次のような式を使用できます。
If(:Cuvette == 11,
:"850 nm"n / :"250 nm"n[Col Min(If(:Cuvette == 12, Row(), .)) + Row() - 1];
);
最終的な数式のタイプは、実際の使用例 (データが「適切に」ソートされているか、複数の値の比較を求めているかなど) に大きく依存します。