数式列を作成して複数の列の最大値を見つける方法<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />数値データの列がいくつかあり (以下の例を参照)、列全体の各行の最大値を見つけるための数式列を作成したいと考えています。助けていただければ幸いです。ありがとう!
値 1 値 2 値 3 最大値 (この列に式を入力します)
1 9 6 9
2 1 5 5
3 7 4 7
4 2 6 6
Re: 数式列を作成して複数の列の最大値を求める方法理由はわかりませんが、txnelsons のコードは私にとっては機能しませんでした。
デバッグ後、最後の行を次のように変更する必要がありました。
namelist[ Loc( as list(maxes`), Max( maxes ) )[1] ];
今はうまくいっているようです
Re: 数式列を作成して複数の列の最大値を求める方法これは、最大列の列名を表示する簡単な例です。
Names Default To Here( 1 );
// Open Data Table: semiconductor capability.jmp
// → Data Table( "semiconductor capability" )
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
dt << New Column( "Example",
character,
formula(
If( Row() == 1,
namelist = {"NPN1", "NPN2", "NPN3", "NPN4"}
);
maxes = [];
For( i = 1, i <= N Items( namelist ), i++,
maxes = maxes || Matrix( Column( namelist[i] )[Row()] )
);
If( Row() <= 5,
Show( maxes )
);
namelist[Loc( maxes, Max( maxes ) )[1]];
)
);
Re: 数式列を作成して複数の列の最大値を求める方法これは均等ではない可能性がありますが、最大値を持つ列の <値> ではなく、最大値を持つ列の <列名> が得られる列式は何ですか?TIA
Re: 数式列を作成して複数の列の最大値を求める方法@txnelsonあなたは魔法使いです! お手伝いありがとう。
Re: 数式列を作成して複数の列の最大値を求める方法例のために作成した構文は機能しませんが、そこから収集したことは、列のリスト全体の最大値を含む新しい列を作成したいということです。数式で指定されたコード (例:
:a * 2 + :p</img>
式に必要な実際のリテラル文字列として入力する必要があります。JMP は、作成される新しい列に渡される前に、式内の JSL の評価を行いません。したがって、使用したい公式は完全に実現されなければなりません。また、コードでは動的である必要があり、そのためには式ステートメントを JSL で作成して式に渡す必要があります。
以下は、その方法の 1 つを示すスクリプトです。
names default to here(1);
dt = Current Data Table();
// The formula that needs to be passed into the new column JSL needs
// to look like
// Max( :NameA, :UniqueX, :Name bb )
// A literal string of ":NameA, :UniqueX, :Name bb" needs to be created
// and then plugged into the JSL and then executed
// ":NameA, :UniqueX, :Name bb" is just an illustration, what the
// make up of the string needs to be derived from the actual column
// names in the data table
FreqList = dt << get column names( string, numeric );
freqString = "";
// build the JSL in the form that is required for the formula
For( i = 1, i <= N Items( FreqList ), i++,
If(
Contains( FreqList[i], "Unique" ) == 1 |
Contains( FreqList[i], "Name" ) == 1,
If( i==1, delim = "", delim = ",");
freqString = freqString || delim || " :" || FreqList[i]
)
);
// Run the command, passing into the formula the command string developed above
Eval( Parse( "dt << New Column (\!"Freq\!", numeric, Formula( Max( " || freqString || " )));" ) );
Re: 数式列を作成して複数の列の最大値を求める方法@txnelson私も同様の問題を抱えています。 複数の列の最大値を取得したい場合。 この例では、FreqList という列のリストがあります。 次のような式を使用して作成したものは、
dt = current data table();
FreqList = dt << get column names( string, numeric );
For( i = N Items( FreqList ), i >= 1, i--,
If( Contains( FreqList[i], "Unique" )== 0,
FreqList= Remove( FreqList, i, 1 ),
Contains( FreqList[i], "Name" )== 0,
FreqList = Remove( FreqList, i, 1 )
)
);
// Then I was thinking something like the following should work,
dt << New Column ("Freq", numeric, Formula(Col Max(FreqList)));私が手動で行う方法は、「Freq」という新しい列を作成することです。 次に、 Maximum(:Freq1,:Freq2,:Freq3,FreqN) のような数式を作成します。これにより、行に基づいて最大頻度を持つ新しい列が作成されます。
これを JSL で行うにはどうすればよいでしょうか?
Re: 数式列を作成して複数の列の最大値を求める方法からの質問@アダンポールスミスそして答えたのは@pmroz結果の列を定義する式で Maximum() 関数を使用します。数式は各行にわたって自動的にループし、数式が適用されます。したがって、行参照を行う必要はありません。
ただし、これをオープン JSL で使用している場合は、列参照に添え字を追加して、どの行を処理するかを示すことができます。
For( theRow = 1, theRow <= 10, theRow++,
:MaxValue[theRow] = Maximum( :Value 1[theRow], :Value 2[theRow], :Value 2[theRow] );
);
『スクリプト ガイド』の JSL に関するドキュメントを参照してください。
ヘルプ==>書籍==>スクリプトガイド
Re: 数式列を作成して複数の列の最大値を求める方法検索したい行が多数ある場合、関数にすべての行を入力するのではなく、行の範囲を選択する関数はありますか?
Re: 数式列を作成して複数の列の最大値を求める方法ありがとう! シンプルなものでなければならないと思っていました。
Re: 数式列を作成して複数の列の最大値を求める方法のMaximum() 関数あなたの代わりにこれを行います。
Maximum(:Value 1, :Value 2, :Value 3)