こんにちは、チームです。
複数の列の減算を行う 1 つのスクリプトを開発するのに助けが必要です。列名と数は変数です。
分析に基づいて変更される可能性がありますが、
同じ行のすべての値の差分を列デルタに入力する必要があります。
以下のサンプルデータ

期待される出力:

複数回使用する必要がある場合は、関数に変換することもできます。
以下に一例を示します。
- 関数
- 正規表現を使用して対象の列をフィルタリングします。
- 各フィルタのため JMP16 が必要
- Loc() と行列計算を使用します
- 値を使用して新しい列デルタを作成します
Names Default To Here(1);
//example datatable
dt = New Table("Untitled",
Add Rows(5),
Compress File When Saved(1),
New Column("Column 1",
Numeric,
"Continuous",
Format("Best", 12),
Set Values([1, 0, 0, 1, 0]),
Set Display Width(55)
),
New Column("Column 2", Numeric, "Continuous", Format("Best", 12), Set Values([0, 2, 3, 0, 0])),
New Column("Column 3",
Numeric,
"Continuous",
Format("Best", 12),
Set Values([0, 3, 0, 0, 0]),
Set Display Width(87)
),
New Column("Column 4", Numeric, "Continuous", Format("Best", 12), Set Values([3, 0, 4, 0, 0])),
New Column("col", Character, "Nominal", Set Values({"a", "a", "a", "a", "a"}))
);
difference_between_min_max = Function({dt_ref, col_prefix_regex},
{Default Local},
//get columnn names of interest based on col_prefix
col_names_all = dt_ref << Get Column Names("Numeric", "String");
col_names_of_interest = Filter Each({val}, col_names_all,
!IsMissing(Regex(val, col_prefix_regex));
);
show(col_names_of_interest);
//all values for columns of interest, transpose for calculations
m = Transpose(dt_ref[0, col_names_of_interest]);
//replace 0 with missing to avoid calculation with those
m[Loc(m, 0)] = .;
//Get max and min values and deduct them
result = V Max(m) - V Min(m);
//Replace missing values with 0 for final results
result[Loc(result,.)] = 0;
//we could return result matrix here OR we can create new column with the function
dt_ref << New Column("delta", Numeric, Continuos, Set Values(result));
);
//example table in this example
difference_between_min_max(dt, "(Column )");
//example table by txnelson
//difference_between_min_max(Current Data Table(), "^(\D{1})$");
に変えることもできますカスタム機能
名前も列の数もわからないと仮定すると、以下のコードは必要な数式を作成し、生成された数式で新しい列を作成します。
Names Default To Here( 1 );
dt = Current Data Table();
// Get the columns
colNames = dt << get column names( string, continuous );
// Build the formula
theExpr = "dt<<NEW column=""></NEW>

私が使用したサンプルデータテーブルを添付します
こんにちは、ジムさん
ご意見ありがとうございます。
ただし、列名は変数制御であり、実行ごとに名前が変更される可能性があります。
その状況でどのようにコーディングすればよいでしょうか?
これが私が使用する公式です。これは、行列内のゼロ以外のエントリをすべて返す行列関数 Loc() に依存しています。
x = :data[Row()] || :data1[Row()] ||
:data2[Row()] || :data3[Row()] ||
:data4[Row()] || :data5[Row()] ||
:data6[Row()] || :data7[Row()] ||
:data8[Row()] || :data9[Row()];
y = Loc( x );
Try( x[y[2]] - x[y[1]], . );
こんにちは 、
データ分析用のスクリプトを作成していましたが、1 つのデータ テーブルに対してのみコード間にこのロジックを実装する必要がありました。
使用できるコードを教えていただけますか
前もって感謝します
なるほど、その場合は個人的にカスタム変換関数を使用することになります。スクリプトツール加える。変換するすべての列 (data1 ~ data10 だと思います) を選択し、[列] メニュー (アドインのインストール後に利用可能) から [カスタム変換] を選択して、次の設定を入力します。

こんにちは、返信ありがとうございます。
私はJMP15を使用しています。使用できるコードを教えてください。
私はJMPの初心者です
前もって感謝します
こんにちは@jinsejoseph
使用したい式の例を教えていただけますか?これは、カスタム変換を使用するもののように思えます。スクリプトツール用のアドイン。
